답안 #671768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671768 2022-12-13T17:59:20 Z Hacv16 코끼리 (Dancing Elephants) (IOI11_elephants) C++17
26 / 100
9000 ms 2876 KB
#include "elephants.h"
#include<bits/stdc++.h>
 
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
const int MAX = 1e5 + 15;
 
int n, l, pos[MAX];
vector<int> x;
 
void init(int n_, int l_, int x_[]){
  n = n_, l = l_;
  x.resize(n);

  for(int i = 0; i < n; i++)
     x[i] = x_[i], pos[i] = x[i];
}

int update(int i, int y){ 
  vector<int> a, b, c;

  int id = 0;
  while(x[id] < pos[i]) id++;

  for(int j = 0; j < id; j++)
    a.emplace_back(x[j]);

  for(int j = id + 1; j < n; j++)
    b.emplace_back(x[j]);

  c.emplace_back(y);

  vector<int> aux(sz(a) + sz(b)), ret(sz(a) + sz(b) + sz(c));

  merge(all(a), all(b), aux.begin());
  merge(all(aux), all(c), ret.begin());

  swap(ret, x);

  int ans = 0, r = -1;
 
  for(int j = 0; j < n; j++) 
    if(x[j] > r) ans++, r = x[j] + l;
 
  pos[i] = y;

  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2848 ms 1316 KB Output is correct
8 Correct 4034 ms 1620 KB Output is correct
9 Execution timed out 9042 ms 2876 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2848 ms 1316 KB Output is correct
8 Correct 4034 ms 1620 KB Output is correct
9 Execution timed out 9042 ms 2876 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2848 ms 1316 KB Output is correct
8 Correct 4034 ms 1620 KB Output is correct
9 Execution timed out 9042 ms 2876 KB Time limit exceeded
10 Halted 0 ms 0 KB -