Submission #1040979

#TimeUsernameProblemLanguageResultExecution timeMemory
1040979ZicrusClosing Time (IOI23_closing)C++17
0 / 100
1080 ms14320 KiB
#include <bits/stdc++.h> #include "closing.h" using namespace std; typedef long long ll; int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w) { vector<ll> distX(n), distY(n), totX(n), totY(n); for (int i = x-1; i >= 0; i--) { distX[i] = distX[i+1] + w[i]; totX[i] = totX[i+1] + distX[i]; } for (int i = x+1; i < n; i++) { distX[i] = distX[i-1] + w[i-1]; totX[i] = totX[i-1] + distX[i]; } for (int i = y-1; i >= 0; i--) { distY[i] = distY[i+1] + w[i]; totY[i] = totY[i+1] + distY[i]; } for (int i = y+1; i < n; i++) { distY[i] = distY[i-1] + w[i-1]; totY[i] = totY[i-1] + distY[i]; } vector<ll> mx(n), mxSum(n+1); for (int i = 0; i < n; i++) { mx[i] = max(distX[i], distY[i]); mxSum[i+1] = mxSum[i] + mx[i]; } ll res = 0; for (int x1 = 0; x1 <= x; x1++) { for (int y1 = x1; y1 <= y; y1++) { for (int y2 = y; y2 < n; y2++) { for (int x2 = x; x2 <= y2; x2++) { ll val = x2-x1+1 + y2-y1+1; if (val <= res) continue; ll cost = 1ll << 62ll; if (x2 < y1) { cost = totX[x1] + totX[x2] + totY[y1] + totY[y2]; } else { cost = totX[x1] + (y1 < x ? -totX[y1-1] : totX[y1-1]) + (x2 > y ? -totY[x2+1] : totY[x2+1]) + totY[y2] + (mxSum[x2+1] - mxSum[y1]); } if (cost <= k) res = val; else break; } } } } return res; }
#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...