# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
248590 | 2020-07-12T20:03:37 Z | davi_bart | Dancing Elephants (IOI11_elephants) | C++14 | 9000 ms | 6008 KB |
#include <bits/stdc++.h> #include "elephants.h" using namespace std; typedef long long ll; //#define int ll mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; vector<int> v(200010); set<int> k; int dim; vector<int>start; void init(int N, int L, int X[]){ n=N; for(int i=0;i<N;i++){ v[i]=X[i]; k.insert(X[i]); } dim=L; int pos=*k.begin(); start.push_back(pos); for(int x:k){ if(x-pos<=dim)continue; pos=x; start.push_back(pos); } } int zero(int i,int y){ k.erase(v[i]); v[i]=y; k.insert(v[i]); start.clear(); int pos=*k.begin(); start.push_back(pos); for(int x:k){ if(x-pos<=dim)continue; pos=x; start.push_back(pos); } return start.size(); } int update(int i,int y){ int q=min(v[i],y); int ini=lower_bound(start.begin(),start.end(),q)-start.begin(); if(ini==0)return zero(i,y); while(start.size()>=ini)start.pop_back(); ini--; k.erase(v[i]); v[i]=y; k.insert(v[i]); auto it=k.lower_bound(start[ini]); int pos=*it; start.push_back(pos); while(it!=k.end()){ int x=*it; it++; if(x-pos<=dim)continue; pos=x; start.push_back(x); } /*cout<<"start: "; for(int i=0;i<start.size();i++)cout<<start[i]<<" "; cout<<endl;*/ return start.size(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1152 KB | Output is correct |
2 | Correct | 1 ms | 1152 KB | Output is correct |
3 | Correct | 1 ms | 1152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1152 KB | Output is correct |
2 | Correct | 1 ms | 1152 KB | Output is correct |
3 | Correct | 1 ms | 1152 KB | Output is correct |
4 | Correct | 1 ms | 1152 KB | Output is correct |
5 | Correct | 1 ms | 1152 KB | Output is correct |
6 | Correct | 1 ms | 1152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1152 KB | Output is correct |
2 | Correct | 1 ms | 1152 KB | Output is correct |
3 | Correct | 1 ms | 1152 KB | Output is correct |
4 | Correct | 1 ms | 1152 KB | Output is correct |
5 | Correct | 1 ms | 1152 KB | Output is correct |
6 | Correct | 1 ms | 1152 KB | Output is correct |
7 | Correct | 3187 ms | 2432 KB | Output is correct |
8 | Correct | 4264 ms | 2780 KB | Output is correct |
9 | Execution timed out | 9085 ms | 6008 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1152 KB | Output is correct |
2 | Correct | 1 ms | 1152 KB | Output is correct |
3 | Correct | 1 ms | 1152 KB | Output is correct |
4 | Correct | 1 ms | 1152 KB | Output is correct |
5 | Correct | 1 ms | 1152 KB | Output is correct |
6 | Correct | 1 ms | 1152 KB | Output is correct |
7 | Correct | 3187 ms | 2432 KB | Output is correct |
8 | Correct | 4264 ms | 2780 KB | Output is correct |
9 | Execution timed out | 9085 ms | 6008 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1152 KB | Output is correct |
2 | Correct | 1 ms | 1152 KB | Output is correct |
3 | Correct | 1 ms | 1152 KB | Output is correct |
4 | Correct | 1 ms | 1152 KB | Output is correct |
5 | Correct | 1 ms | 1152 KB | Output is correct |
6 | Correct | 1 ms | 1152 KB | Output is correct |
7 | Correct | 3187 ms | 2432 KB | Output is correct |
8 | Correct | 4264 ms | 2780 KB | Output is correct |
9 | Execution timed out | 9085 ms | 6008 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |