# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
8018 |
2014-08-27T06:02:27 Z |
jhs7jhs |
막대기 (KOI13_game) |
C++ |
|
20 ms |
4724 KB |
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
pair<int,int> a[100000];
vector<int> r;
int n,l;
long long rmax[100000]={0},dp[100000][2]={0},ans=0;
int main()
{
int i;
long long t;
scanf("%d%d",&n,&l);
for(i=0;i<n;i++){
scanf("%d%d",&a[i].first,&a[i].second);
r.push_back(a[i].second);
}
sort(r.begin(),r.end());
sort(a,a+n);
for(i=0;i<n;i++){
if(i==0 || a[i].first!=a[i-1].first) t=0;
dp[i][1] = t + (long long)(l + abs(a[i].first-a[i].second));
dp[i][0] = rmax[(lower_bound(r.begin(),r.end(),a[i].second) - r.begin())] + (long long)(l + abs(a[i].first-a[i].second));
rmax[(lower_bound(r.begin(),r.end(),a[i].second) - r.begin())] = dp[i][1];
if(t<dp[i][0]) t=dp[i][0];
if(ans < dp[i][0]) ans = dp[i][0];
if(ans < dp[i][1]) ans = dp[i][1];
}
printf("%lld\n",ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4336 KB |
Output is correct |
2 |
Correct |
0 ms |
4336 KB |
Output is correct |
3 |
Correct |
0 ms |
4336 KB |
Output is correct |
4 |
Correct |
0 ms |
4336 KB |
Output is correct |
5 |
Correct |
0 ms |
4336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
4724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4336 KB |
Output is correct |
2 |
Correct |
0 ms |
4336 KB |
Output is correct |
3 |
Correct |
0 ms |
4336 KB |
Output is correct |
4 |
Correct |
0 ms |
4336 KB |
Output is correct |
5 |
Correct |
0 ms |
4336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
4336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
4336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |