# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1019603 | 2024-07-11T04:51:30 Z | LIF | 봉쇄 시간 (IOI23_closing) | C++17 | 1000 ms | 10992 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; //if(r2 - l2 + 1 + r1 - l1 + 1 == 98)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; } for(int i=1;i<=N;i++)c[i] = max(a[i],b[i]); 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] = suc[i-1] + c[i]; // it can't be written as max(sua[i],sub[i]) since it can larger than both of them. } //cout<<suc[50] - suc[1]<<endl; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1064 ms | 10992 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 3 ms | 348 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 3 ms | 348 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 17 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 24 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 348 KB | Output is correct |
17 | Correct | 2 ms | 348 KB | Output is correct |
18 | Incorrect | 7 ms | 348 KB | 7th lines differ - on the 1st token, expected: '27', found: '24' |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 3 ms | 348 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 17 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 24 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 348 KB | Output is correct |
17 | Correct | 2 ms | 348 KB | Output is correct |
18 | Incorrect | 7 ms | 348 KB | 7th lines differ - on the 1st token, expected: '27', found: '24' |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |