# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897192 | 2024-01-02T17:12:04 Z | ErJ | Closing Time (IOI23_closing) | C++17 | 1000 ms | 18004 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define vvi vector<vector<ll>> #define vs vector<string> #define vc vector<char> #define vb vector<bool> #define vp vector<pair<ll, ll>> #define pp pair<ll, ll> #define qi queue<ll> #define qp queue<pp> #define pqi priority_queue<ll> #define pqp priority_queue<pp> #define mi map<ll, ll> #define mpi map<pp, ll> #define mip map<ll, pp> #define mpp map<pp, pp> #define mb map<ll, bool> #define si set<ll> #define sp set<pp> #define mod 1000000007 #define rep(a, b) for(int a = 0; a < (b); a++) #define inf 10000000000 int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) { vector<ll> distX(N); vector<ll> distY(N); vector<ll> distXY(N); distX[X] = 0; distX[Y] = 0; for (int i = X + 1; i < N; i++) { distX[i] = distX[i - 1] + W[i - 1]; } for (int i = X - 1; i >= 0; i--) { distX[i] = distX[i + 1] + W[i]; } for (int i = Y + 1; i < N; i++) { distY[i] = distY[i - 1] + W[i - 1]; } for (int i = Y - 1; i >= 0; i--) { distY[i] = distY[i + 1] + W[i]; } for (int i = 0; i < N; i++) { distXY[i] = max(distX[i], distY[i]); } vi prefX(N + 1); vi prefY(N + 1); vi prefXY(N + 1); prefX[0] = 0; prefY[0] = 0; prefXY[0] = 0; for (int i = 1; i < prefX.size(); i++) { prefX[i] = prefX[i - 1] + distX[i - 1]; prefY[i] = prefY[i - 1] + distY[i - 1]; prefXY[i] = prefXY[i - 1] + distXY[i - 1]; } int ans = 0; for (int i = 0; i <= X; i++) { for (int j = X; j < N; j++) { ll cena = prefX[j + 1] - prefX[i]; int ans2 = 1; ans2 += j - i + 1; ll K2 = K - cena; if (K2 < 0) continue; int l = Y, r = Y; while (K2 > 0) { ll left = inf; if (l > 0) { if (l - 1 <= j) { left = distXY[l - 1] - distX[l - 1]; } else { left = distY[l - 1]; } } ll right = inf; if (r < N - 1) { if (r + 1 <= j) { right = distXY[r + 1] - distX[r + 1]; } else { right = distY[r + 1]; } } if (K2 - min(left, right) < 0) break; if (left < right && K2 - left >= 0) { K2 -= left; l--; ans2++; } else if (K2 - right >= 0) { K2 -= right; r++; ans2++; } } ans = max(ans, ans2); //cout << ans << " " << i << " " << j << endl; } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1048 ms | 18004 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '30', found: '34' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '30', found: '34' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '30', found: '34' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |