Submission #17667

#TimeUsernameProblemLanguageResultExecution timeMemory
17667chatterboy막대기 (KOI13_game)C++98
0 / 100
1000 ms1864 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...