답안 #1096178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096178 2024-10-04T03:58:49 Z MtSaka 코끼리 (Dancing Elephants) (IOI11_elephants) C++17
0 / 100
0 ms 348 KB
#include "elephants.h"
#include"bits/stdc++.h"
#define overload(a,b,c,d,...) d
#define rep1(a) for(ll _=0;_<(ll)a;++_)
#define rep2(i,a) for(ll i=0;i<(ll)(a);++i)
#define rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) overload(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(i,a) for(ll i=(ll)(a)-1;i>=0;--i)
#define rrep2(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);--i)
#define rrep(...) overload(__VA_ARGS__,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using ld=long double;
using vi=vector<int>;
using vl=vector<ll>;
template<typename T,typename U>inline bool chmin(T&a,const U&b){return (a>b?a=b,true:false);}
template<typename T,typename U>inline bool chmax(T&a,const U&b){return (a<b?a=b,true:false);}

int n;
vector<int>x;
vector<int>xs;
int l;
void init(int N, int L, int X[])
{
  n=N;
  x=vector<int>(X,X+N);
  xs=x;
  sort(all(xs));
  l=L;
}

int update(int id, int y)
{
  auto it=lower_bound(all(xs),x[id])-xs.begin();
  rep(i,it,n-1)xs[i]=xs[i+1];
  it=lower_bound(xs.begin(),xs.begin()+n-1,y)-xs.begin();
  rrep(i,it+1,n)xs[i]=xs[i-1];
  xs[it]=y;
  int ans=1;
  int now=xs[0];
  rep(i,1,n){
    if(xs[i]-now>l){
      now=xs[i];
      ans++;
    }
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -