Submission #17667

# Submission time Handle Problem Language Result Execution time Memory
17667 2016-01-10T11:57:45 Z chatterboy 막대기 (KOI13_game) C++
0 / 100
1000 ms 1864 KB
#include <cstdio>
#include <algorithm>
using namespace std;
#define MAXN 100001
struct Stick {
	int t, d;
};
int N, L;
Stick A[MAXN];
int solve(int p) {
	int 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].t>=A[p].t && A[pp].d>=A[p].d))
			ret = max(ret, solve(pp));
	}
	return ret+L+abs(A[p].t-A[p].d);
}
int main() {
	scanf("%d%d", &N, &L);
	for (int i=1; i<=N; ++i) scanf("%d%d", &A[i].t, &A[i].d);
	int sol = 0;
	for (int i=1; i<=N; ++i)
		sol = max(sol, solve(i));
	printf("%d", sol);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Incorrect 0 ms 1864 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 1860 KB Program timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1864 KB Output is correct
2 Incorrect 9 ms 1864 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 1860 KB Program timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 1860 KB Program timed out
2 Halted 0 ms 0 KB -