Submission #919945

#TimeUsernameProblemLanguageResultExecution timeMemory
919945LalicDancing Elephants (IOI11_elephants)C++17
0 / 100
2 ms8536 KiB
#include <bits/stdc++.h> #include "elephants.h" using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 15e4+10; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9+7; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int arr[MAXN], proc[MAXN]; int l, n; void init(int N, int L, int X[]) { for(int i=0;i<N;i++) arr[i]=X[i], proc[i]=X[i]; l=L; n=N; } int update(int i, int y) { int id; for(int j=0;j<n;j++){ if(proc[j]==arr[i]){ id=j; break; } } int val=proc[id]; if(val>y){ bool foi=0; for(int j=id-1;j>=0;j--){ proc[j+1]=proc[j]; if(proc[j]<y){ proc[j+1]=y; foi=1; break; } } if(!foi) proc[0]=y; } else{ bool foi=0; for(int j=id+1;j<n;j++){ proc[j-1]=proc[j]; if(proc[j]>y){ proc[j-1]=y; foi=1; break; } } if(!foi) proc[n-1]=y; } int ans=0, curr=-l-1; for(int j=0;j<n;j++){ if(proc[j]<=curr+l) continue; ans++; curr=proc[j]; } return ans; }

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:42:6: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |  int val=proc[id];
      |      ^~~
#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...