제출 #954389

#제출 시각아이디문제언어결과실행 시간메모리
954389vjudge1코끼리 (Dancing Elephants) (IOI11_elephants)C++98
26 / 100
9094 ms9308 KiB
#include "elephants.h" #include <bits/stdc++.h> using namespace std; int n, k; int diff[150001]; pair<int, int> arr[150001]; bool compare(const pair<int, int> &a, const pair<int, int> &b){ return a.second<b.second; } void init(int N, int L, int X[]){ n = N; k=L; for(int i=0; i<n; i++){ arr[i].first=X[i]; arr[i].second=i; } } int update(int i, int y){ sort(arr, arr+n, compare); arr[i].first=y; sort(arr, arr+n); for(int i=0; i<n-1; i++) diff[i]=arr[i+1].first-arr[i].first; int cnt=0, l=0, r=0, ans=0; while(l<n){ r=l; cnt=0; while(r<n && diff[r]+cnt<=k){ cnt+=diff[r]; r++; } ans++; l=r+1; } return ans; }
#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...