Submission #955217

#TimeUsernameProblemLanguageResultExecution timeMemory
95521742kangarooClosing Time (IOI23_closing)C++17
0 / 100
1060 ms9932 KiB
#include "closing.h" #include <vector> int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { using namespace std; if (X > Y) swap(X, Y); vector<int> distX(N), distY(N); distX[X] = 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]; } distY[Y] = 0; 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]; } int ma = 0; for (int i = 0; i <= X; ++i) { int co = 0; for (int j = i; j < N; ++j) { co += distX[j]; if (j >= X) { int act = i - j + 1; if (co > K) continue; else { int co2 = K - co; int lon = 0; int l = 0, r = Y; int cos = 0; for (int k = 0; k < Y; ++k) { if (i <= k && k <= j && distX[k] > distY[k]); else if (i <= k && k <= j) cos += distY[k] - distX[k]; else cos += distY[k]; } while (l < Y && r < N) { while (l < Y && r < N && cos > co2) { if (i <= l && l <= j && distX[l] > distY[l]); else if (i <= l && l <= j) cos -= distY[l] - distX[l]; else cos -= distY[l]; l++; } while (r < N && cos <= co2) { lon = max(lon, r - l + 1); r++; if (r == N) break; if (i <= r && r <= j && distX[r] > distY[r]); else if (i <= r && r <= j) cos += distY[r] - distX[r]; else cos += distY[r]; } } act += lon; ma = max(ma, act); } } } } return ma; }
#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...
#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...