# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
17669 |
2016-01-10T12:12:17 Z |
chatterboy |
막대기 (KOI13_game) |
C++14 |
|
1000 ms |
2644 KB |
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MAXN 100001
typedef long long ll;
struct Stick {
ll t, d;
};
int N;
ll L;
Stick A[MAXN];
ll solve(int p) {
ll ret = 0;
for (int pp=1; pp<=N; ++pp) if (p != pp) {
if ((A[pp].t==A[p].t && A[pp].d>A[p].d) || (A[pp].d==A[p].d && A[pp].t>A[p].t))
ret = max(ret, solve(pp)+L+abs(A[pp].t-A[pp].d));
}
return ret;
}
int main() {
scanf("%d%lld", &N, &L);
for (int i=1; i<=N; ++i) scanf("%lld%lld", &A[i].t, &A[i].d);
ll sol = 0;
for (int i=1; i<=N; ++i)
sol = max(sol, solve(i)+L+abs(A[i].t-A[i].d));
printf("%lld", sol);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2644 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2644 KB |
Output is correct |
2 |
Incorrect |
11 ms |
2644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |