Submission #1104164

#TimeUsernameProblemLanguageResultExecution timeMemory
1104164NxmkxingClosing Time (IOI23_closing)C++17
0 / 100
45 ms14940 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int M = 1e5 + 10; ll n, x, y, p, qs[M], a[M], b[M]; int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n = N, x = X, y = Y, p = K; for (int i = 0; i < n - 1; i++) { qs[i+1] = qs[i] + W[i]; } if (x > y) swap(x, y); for (int i = 0; i <= x; i++) { a[i] = qs[x] - qs[i]; } for (int i = y; i < n; i++) { a[i] = qs[i] - qs[y]; } for (int i = x; i <= y; i++) { a[i] = min(qs[i] - qs[x], qs[y] - qs[i]); b[i] = max(qs[i] - qs[x], qs[y] - qs[i]) - a[i]; } for (int i = 1; i < n; i++) { a[i] += a[i-1]; b[i] += b[i-1]; } int ans = 0; for (int i = 0; i <= x; i++) { for (int j = y; j < n; j++) { ll sum = a[j] - (i > 0 ? a[i-1] : 0); int lv1 = j - i + 1; if (sum <= p) ans = max(ans, lv1); for (int k = x + 1; k < y; k++) { for (int l = k; l < y; l++) { ll rollback = a[l] - a[k-1]; ll upd = b[l] - b[k-1]; int lv2 = l - k + 1; if (sum - rollback <= p) { ans = max(ans, lv1 - lv2); } if (sum + upd <= p) { ans = max(ans, lv1 + lv2); } } } } } return ans; }
#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...