当前位置:网站首页>Hoj 2245 planktonic triangle cell (Mathematics)
Hoj 2245 planktonic triangle cell (Mathematics)
2022-07-07 21:00:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Time Limit: 500 MS Memory Limit: 50000 K Total Submit: 129(38 users) Total Accepted: 66(34 users) Rating: Special Judge: No | Time Limit: 500 MS | Memory Limit: 50000 K | Total Submit: 129(38 users) | Total Accepted: 66(34 users) | Rating: | Special Judge: No |
---|---|---|---|---|---|---|
Time Limit: 500 MS | Memory Limit: 50000 K | |||||
Total Submit: 129(38 users) | Total Accepted: 66(34 users) | Rating: | Special Judge: No | |||
Description | ||||||
As you can see .Zoidtrip It's a casual game …… Players need to control a speed of 45 degrees downward v Triangle cell that keeps moving , Keep avoiding horizontal obstacles , Each click on the screen can change the direction of travel .[ Can tilt to the left ( Right )45° Change to oblique right ( Left )45°] Now , Yes n Layer obstacle . The first i Layer obstacles can be seen from the abscissa l[i]~r[i] Through the range of ( contain l[i] And r[i]), The first i Obstacles on the first floor and i-1 The distance between layer obstacles is d[i]. Excuse me, , Assuming that the direction can be changed infinitely , What level can you advance to at most ? We stipulate that the birth position of players is 0 layer 、 Abscissa for 0 The place of . You can change direction at any real time . | ||||||
Input | ||||||
Multiple sets of test data . The first line of each group of test data is two positive integers n and v. Next n That's ok , Each row 3 It's an integer l[i] , r[i] , d[i]. ( N <= 2000000.0 <= All data < 2^31 ) | ||||||
Output | ||||||
For each set of data . Output one line , Include an integer , Represents the maximum number of layers to advance to . | ||||||
Sample Input | ||||||
3 7 1 3 1 4 10 5 8 10 1 4 1 1 1 1 2 5 10 1 1 1 3 5 2 | ||||||
Sample Output | ||||||
2 4 | ||||||
Hint | ||||||
“ The first i Obstacles on the first floor and i-1 The distance between layer obstacles is d[i]” therefore d[1] Is the distance between the first floor and the zero floor . Example 1 Explain, for example, the following : We can move the birth position to the right and down to the first floor, with the coordinates of 1 The place of . Next, you can continue to move all the way down to the right until the coordinate of the second layer is 6 The place of . But you can't move to the third floor anyway 8~10 Between . Example 2 Description such as the following : (0,0)->(1,1)->(2,2)->(3,1)->(4,3) So get to the fourth floor . | ||||||
Source | ||||||
The 5th Harbin University of Technology ACM Programming Competition |
PS:
hold Triangle cells are found at the leftmost and rightmost distance that can be reached on each layer and can avoid obstacles !
The code is as follows :
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define maxn 2000047
LL l[maxn], r[maxn], d[maxn];
int main()
{
LL n, v;
while(scanf("%lld%lld",&n,&v)!=EOF)
{
LL L = 0,R = 0;
int ans = 0;
for(int i=0; i<n; i++)
{
scanf("%lld%lld%lld",&l[i],&r[i],&d[i]);
}
for(int i = 0; i < n; i++)
{
if(l[i] > r[i])
{
LL t = r[i];
r[i] = l[i];
l[i] = t;
}
L-=d[i];
R+=d[i];
L = max(l[i],L);
R = min(r[i],R);
if(L > R)
{
break;
}
ans++;
}
if(v == 0)
ans = 0;
printf("%d\n",ans);
}
return 0;
}
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116288.html Link to the original text :https://javaforall.cn
边栏推荐
- Cantata9.0 | new features
- Helix QAC 2020.2新版静态测试工具,最大限度扩展了标准合规性的覆盖范围
- 目前股票开户安全吗?可以直接网上开户吗。
- Écrivez une liste de sauts
- Measure the height of the building
- ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- Ubuntu安装mysql8遇到的问题以及详细安装过程
- OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
- MySQL约束之默认约束default与零填充约束zerofill
- 刚开户的能买什么股票呢?炒股账户安全吗
猜你喜欢
OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
神兵利器——敏感文件发现工具
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
Nebula importer data import practice
C语言 整型 和 浮点型 数据在内存中存储详解(内含原码反码补码,大小端存储等详解)
智能软件分析平台Embold
Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
Small guide for rapid formation of manipulator (11): standard nomenclature of coordinate system
Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system
AADL Inspector 故障树安全分析模块
随机推荐
C语言 整型 和 浮点型 数据在内存中存储详解(内含原码反码补码,大小端存储等详解)
C language helps you understand pointers from multiple perspectives (1. Character pointers 2. Array pointers and pointer arrays, array parameter passing and pointer parameter passing 3. Function point
Introduction to referer and referer policy
Airiot helps the urban pipe gallery project, and smart IOT guards the lifeline of the city
Codeforces round 296 (Div. 2) A. playing with paper[easy to understand]
如何满足医疗设备对安全性和保密性的双重需求?
【网络原理的概念】
H3C s7000/s7500e/10500 series post stack BFD detection configuration method
软件缺陷静态分析 CodeSonar 5.2 新版发布
恶魔奶爸 B2 突破语法,完成正统口语练习
CodeSonar网络研讨会
Codeforces Round #296 (Div. 2) A. Playing with Paper[通俗易懂]
openGl超级宝典学习笔记 (1)第一个三角形「建议收藏」
国家正规的股票交易app有哪些?使用安不安全
Codesonar Webinar
恶魔奶爸 A1 语音听力初挑战
Flask1.1.4 werkzeug1.0.1 source code analysis: Routing
部署、收回和删除解决方式—-STSADM和PowerShell「建议收藏」
Klocwork code static analysis tool
95年专注安全这一件事 沃尔沃未来聚焦智能驾驶与电气化领域安全