Submission #963649

#TimeUsernameProblemLanguageResultExecution timeMemory
963649AmrDancing Elephants (IOI11_elephants)C++17
26 / 100
12 ms8792 KiB
#include "elephants.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define sz size() const int N = 102; ll n , l; ll a[N]; ll b[N]; void init(int N, int L, int X[]) { n = N; l = L; for(int i = 0; i < n; i++) a[i] = X[i],b[i] = X[i]; sort(a,a+n); } int update(int i, int y) { ll x = b[i],in = 0; b[i] = y; for(int i = 0; i < n; i++) { if(a[i]==x) {in = i; break;} } a[in] = y; for(int i = in+1; i < n; i++) if(a[i-1]>a[i]) swap(a[i-1],a[i]); for(int i = in-1; i >= 0; i--) if(a[i+1]<a[i]) swap(a[i+1],a[i]); //for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl; ll cnt = 1, dis = 0; for(int i = 1; i < n; i++) { //cout << v[i] << " "; if(dis+a[i]-a[i-1]>l) { cnt++; dis = 0; } else dis+=a[i]-a[i-1]; } return cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...