# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
791359 | 2023-07-24T03:49:54 Z | Username4132 | Izbori (COCI22_izbori) | C++14 | 16 ms | 5004 KB |
#include<iostream> #include<map> #include<vector> using namespace std; using pii = pair<int, int>; using ll = long long; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define PB push_back #define F first #define S second const int MAXN = 200010; int n, arr[MAXN]; ll ans; pii calc[3*MAXN]; map<int, vector<int>> mp; int main(){ scanf("%d", &n); forn(i, n) scanf("%d", arr+i), mp[arr[i]].PB(i); forn(i, 3*n+10) calc[i]={-1, -1}; for(auto pr:mp){ int sz = pr.S.size(); vector<int> toClear; forn(i, sz){ int pa = pr.S[i], bnd = (i==sz-1)? n : pr.S[i+1]; bool yes=true; while(pa<bnd){ int val = 2*i-pa+n; if(calc[val].F==-1){ if(!yes) break; if(val>=n-pr.S[0]) calc[val]={min(2*i+1, pa+1), pa}; else calc[val]={1, pa}; toClear.PB(val); } else{ if(yes) calc[val].F+=pa-calc[val].S-1; calc[val].S=pa; } ans+=calc[val].F; yes=false; ++pa; } } for(int el:toClear) calc[el]={-1, -1}; } printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 308 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 308 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 5004 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 308 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |