# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894887 | 2023-12-29T07:22:34 Z | adkjt | Pilot (NOI19_pilot) | C++14 | 73 ms | 73180 KB |
#include<bits/stdc++.h> using namespace std; #define f first #define s second #define ll long long vector<ll> g[1111111]; set<pair<ll,ll>> s; ll a[1111111]; long long ans[1111111],ind[1111111]; int main() { ll n,q,hmx=0; scanf("%lld %lld",&n,&q); for(int i=1;i<=n;i++) ind[i]=ind[i-1]+i; for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); hmx=max(hmx,a[i]); g[a[i]].push_back(i); } //s.insert({0,0}); for(int i=1;i<=hmx;i++) { ans[i]=ans[i-1]; //printf("Y"); for(auto x:g[i]) { //printf("OO"); if(s.empty()){ ans[i]+=1,s.insert({x,x}); continue; } int cnt=1,rch=0,lch=0; auto it=s.lower_bound({x,x}); if(it==s.end()) rch=1; auto itr=--it; it++; pair<int,int> left=*itr,right=*it; /*for(auto p=s.begin();p!=s.end();p++) printf("%d,%d ",(*p).f,(*p).s);*/ //printf("\n%d %d %d %d %d\n%d %d\n",x,left.f,left.s,right.f,right.s,lch,rch); if(!rch&&left.s==x-1&&right.f==x+1) { ans[i]-=ind[left.s-left.f+1]; ans[i]-=ind[right.s-right.f+1]; ans[i]+=ind[right.s-left.f+1]; s.erase(it); s.erase(itr); s.insert({left.f,right.s}); } else if(!rch&&right.f==x+1) { ans[i]-=ind[right.s-right.f+1]; ans[i]+=ind[right.s-x+1]; s.erase(it); s.insert({x,right.s}); } else if(left.s==x-1) { ans[i]-=ind[left.s-left.f+1]; ans[i]+=ind[x-left.f+1]; s.erase(itr); s.insert({left.f,x}); } else ans[i]+=1,s.insert({x,x}); //printf("LL"); } } for(int i=1;i<=q;i++) { int qu; scanf("%lld",&qu); if(qu>hmx) qu=hmx; printf("%lld\n",ans[qu]); } /* for(int i=1;i<=hmx;i++) printf("%lld ",ind[i]);*/ return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
11 | Runtime error | 28 ms | 60252 KB | Execution killed with signal 6 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
11 | Runtime error | 28 ms | 60252 KB | Execution killed with signal 6 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
11 | Runtime error | 28 ms | 60252 KB | Execution killed with signal 6 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 73 ms | 73180 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 36944 KB | Output is correct |
2 | Correct | 44 ms | 36692 KB | Output is correct |
3 | Correct | 40 ms | 36436 KB | Output is correct |
4 | Correct | 41 ms | 36696 KB | Output is correct |
5 | Correct | 41 ms | 36432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 43936 KB | Output is correct |
2 | Correct | 50 ms | 43648 KB | Output is correct |
3 | Correct | 51 ms | 43692 KB | Output is correct |
4 | Correct | 53 ms | 43852 KB | Output is correct |
5 | Correct | 53 ms | 43856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
11 | Runtime error | 73 ms | 73180 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
11 | Runtime error | 28 ms | 60252 KB | Execution killed with signal 6 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 29784 KB | Output is correct |
2 | Correct | 9 ms | 35676 KB | Output is correct |
3 | Correct | 10 ms | 37724 KB | Output is correct |
4 | Correct | 6 ms | 29788 KB | Output is correct |
5 | Correct | 10 ms | 37760 KB | Output is correct |
6 | Correct | 6 ms | 29788 KB | Output is correct |
7 | Correct | 10 ms | 37724 KB | Output is correct |
8 | Correct | 6 ms | 29788 KB | Output is correct |
9 | Correct | 10 ms | 35676 KB | Output is correct |
10 | Correct | 6 ms | 29668 KB | Output is correct |
11 | Runtime error | 28 ms | 60252 KB | Execution killed with signal 6 |
12 | Halted | 0 ms | 0 KB | - |