# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411169 | 2021-05-24T13:11:48 Z | 송준혁(#7506) | JOI15_cardgame2 (JOI15_cardgame2) | C++17 | 1 ms | 204 KB |
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define lb lower_bound #define MOD 1000000007 #define INF (1ll<<62) using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, ans; bool D[550][550][550][2]; int A[550], B[550], C[550], S[550]; int main(){ scanf("%d", &N); for (int i=1; i<=N; i++) scanf("%d %d %d", &A[i], &B[i], &C[i]), S[i]=S[i-1]+C[i]; D[1][2][3][0] = D[1][2][3][1] = true; ans = max(C[1], C[3]); for (int i=1; i<=N; i++) for (int j=i+1; j<=N+1; j++) for (int k=j+1; k<=N+2; k++){ if (k == j+1){ for (int l=1; l<i; l++){ if (D[l][i][j][0] && (A[l] == A[i] || B[l] == B[i])){ D[i][j][k][0] = true; ans = max(ans, S[k-1] - C[j]); } if (D[l][i][j][0] && k<=N && (A[l] == A[k] || B[l] == B[k])){ D[i][j][k][1] = true; ans = max(ans, S[k] - C[i] - C[j]); } } } else{ if (D[i][j][k-1][1] && (A[k-1] == A[k] || B[k-1] == B[k])){ D[i][j][k][1] = true; ans = max(ans, S[k] - C[i] - C[j]); } if (D[i][j][k-1][1] && (A[k-1] == A[i] || B[k-1] == B[i])){ D[i][j][k][0] = true; ans = max(ans, S[k-1] - C[j]); } } } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |