제출 #1241007

#제출 시각아이디문제언어결과실행 시간메모리
1241007candi_ositos코끼리 (Dancing Elephants) (IOI11_elephants)C++20
0 / 100
0 ms320 KiB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> ap;
vector <int> pe;
int c;
void init(int N, int L, int X[]){
  n=N;
  c=L-1;
  ap.resize(n);
  pe.resize(n);
  for(int i=0; i<n; ++i){
    pe[i]=X[i];
    ap[i]=X[i];
  }
  sort(pe.begin(), pe.end());
}
int update(int i, int y){
  int cnt=0;
  for(int j=0; j<n; ++j){
    if(pe[j]==ap[i]){
      pe.erase(pe.begin()+j, pe.begin()+j+1);
      break;
    }
  }
  pe.push_back(y);
  for(int j=n-2; j>=0; --j){
    if(pe[j]>pe[j+1]){
      int aux=pe[j];
      pe[j]=pe[j+1];
      pe[j+1]=aux;
    }
    else if(pe[j]==ap[j+1]){
      int aguss=pe[j];
      pe[j]=pe[j+1];
      pe[j+1]=aguss;
      break;
    }
    else{
      break;
    }
  }
  ap[i]=y;
  int cp=-1;
  for(int j=0; j<n; ++j){
    if(cp==-1 || cp+c<pe[j]){
      ++cnt;
      cp=pe[j];
    }
  }
  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...