제출 #1249158

#제출 시각아이디문제언어결과실행 시간메모리
1249158redacodeDancing Elephants (IOI11_elephants)C++20
26 / 100
9093 ms5700 KiB
#include "elephants.h" #include "bits/stdc++.h" using namespace std; int n; int l; bool cmp(pair<int, int>& a, pair<int, int>& b) { return a.second < b.second; } set<pair<int, int> > A; /* void sort_map(map<int, int>& M) { A.clear(); for (auto& it : M) { A.push_back(it); } sort(A.begin(), A.end(), cmp); } */ map<int,int> pos; void init(int N, int L, int X[]) { n = N; l =L; for(int i=0;i<n;i++){ pos[i]=X[i]; A.insert({X[i],i}); } } int update(int i, int y) { if(n==1){ return 1; } A.erase({pos[i],i}); pos[i]=y; A.insert({pos[i],i}); //sort_map(pos); int cnt =1; int start = (*A.begin()).first; for(auto& it: A){ if(it.first-start>l){ start = it.first; cnt++; } } 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...