# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897271 | ErJ | Closing Time (IOI23_closing) | C++17 | 1068 ms | 17992 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
vector<ll> distXY2(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]);
distXY2[i] = min(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];
}
ll ans = 0;
ans = 0;
//int ans = 0;
for (int i = 0; i <= X; i++) {
for (int j = X; j < N; j++) {
ll cena = prefX[j + 1] - prefX[i];
ll ans2 = 1;
ans2 += j - i + 1;
ll K2 = K - cena;
if (K2 < 0) continue;
ll l = Y, r = Y;
while (K2 > 0) {
ll left = inf;
if (l > 0) {
if (l - 1 <= j && l - 1 >= i) {
left = distXY[l - 1] - distX[l - 1];
}
else {
left = distY[l - 1];
}
}
ll right = inf;
if (r < N - 1) {
if (r + 1 <= j && r + 1 >= i) {
right = distXY[r + 1] - distX[r + 1];
}
else {
right = distY[r + 1];
}
}
//cout << K2 << " " << left << " " << right << endl;
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 << "AAAAA" << ans2 << " " << i << " " << j << endl;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |