# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086135 | urd05 | Closing Time (IOI23_closing) | C++17 | 59 ms | 13532 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 "closing.h"
#include <bits/stdc++.h>
using namespace std;
int n;
long long pos[3005];
long long save[3005];
vector<long long> v1;
vector<long long> v2;
int x,y;
long long k;
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;
k=K;
for(int i=0;i<n-1;i++) {
pos[i+1]=pos[i]+W[i];
}
int l=x;
int r=y;
while (1) {
if (l==0&&r==n-1) {
break;
}
if (l!=0&&(r==n-1||pos[x]-pos[l-1]<=pos[r+1]-pos[y])) {
l--;
v2.push_back(pos[x]-pos[l]);
}
else {
r++;
v2.push_back(pos[r]-pos[y]);
}
}
l=x;
r=y;
while (1) {
if (l==y&&r==x) {
break;
}
if (l!=y&&(r==x||pos[l+1]-pos[x]-save[l+1]<=pos[y]-pos[r-1]-save[r-1])) {
l++;
v1.push_back(pos[l]-pos[x]-save[l]);
save[l]=pos[l]-pos[x];
}
else {
r--;
v1.push_back(pos[y]-pos[r]-save[r]);
save[r]=pos[y]-pos[r];
}
}
int ret=0;
for(int i=0;i<=v2.size();i++) {
long long sum=0;
for(int j=0;j<i;j++) {
sum+=v2[j];
}
if (sum>k) {
break;
}
int cnt=i;
for(int j=0;j<v1.size();j++) {
if (sum+v1[j]<=k) {
sum+=v1[j];
cnt++;
}
else {
break;
}
}
ret=max(ret,cnt);
}
return ret+2;
}
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... |