# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019581 | 2024-07-11T04:19:39 Z | LIF | Closing Time (IOI23_closing) | C++17 | 1000 ms | 14932 KB |
#include "closing.h" #include<bits/stdc++.h> #include <vector> using namespace std; long long int a[500005]; long long int b[500005]; long long int c[500005]; long long int sua[50005]; long long int sub[50005]; long long int suc[50005]; int flag[50005]; long long int kk; bool check(int l1,int r1,int l2,int r2) { flag[l1] += 1; flag[r1+1] -= 1; flag[l2] += 2; flag[r2+1] -= 2; vector<int> v; v.push_back(l1);v.push_back(r1+1);v.push_back(l2);v.push_back(r2+1); sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); int num = 0; long long int allsu = 0; for(int i=0;i<v.size()-1;i++) { int nowx = v[i]; int nextx = v[i+1]; num += flag[v[i]]; // cout<<num<<endl; //calculate: v[i],v[i+1]-1; if(num == 1)allsu += sua[nextx-1] - sua[nowx-1]; if(num == 2)allsu += sub[nextx-1] - sub[nowx-1]; if(num == 3)allsu += suc[nextx-1] - suc[nowx-1]; } flag[l1] = 0;flag[l2] = 0;flag[r1+1] = 0;flag[r2+1] = 0; // cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<" "<<allsu<<endl; if(allsu > kk)return false; return true; } int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W) { kk = K; for(int i=0;i<U.size();i++)U[i]+=1; for(int i=0;i<V.size();i++)V[i]+=1; X+=1; Y+=1; //process X; long long int now = 0; for(int i=X-1;i>=1;i--) { now += W[i-1]; a[i] = now; } now = 0; for(int i=X+1;i<=N;i++) { now += W[i-2]; a[i] = now; } now = 0; for(int i=Y-1;i>=1;i--) { now += W[i-1]; b[i] = now; } now = 0; for(int i=Y+1;i<=N;i++) { now += W[i-2]; b[i] = now; } a[X] = 0; b[Y] = 0; for(int i=1;i<=N;i++) { sua[i] = sua[i-1] + a[i]; sub[i] = sub[i-1] + b[i]; suc[i] = max(sua[i],sub[i]); } int all = 0; for(int l1=1;l1<=X;l1++) { for(int r1=X;r1<=N;r1++) { int l2 = 1; int r2 = Y; while(l2 <= Y) { bool ad = false; while(check(l1,r1,l2,r2) == true && r2<=N) { ad = true; r2++; } if(ad == true)r2 -= 1; if(r2 > N)break; //otherwise, it is true if(check(l1,r1,l2,r2) == true)all = max(all,r1 - l1 + 1 + r2 - l2 + 1); l2++; } } } return all; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1058 ms | 14932 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 1 ms | 2392 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
3 | Halted | 0 ms | 0 KB | - |