답안 #447778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447778 2021-07-27T13:55:38 Z dxz05 코끼리 (Dancing Elephants) (IOI11_elephants) C++14
0 / 100
0 ms 332 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")

#include "elephants.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 3e2;

int N, L;
int X[MAXN], A[MAXN];
void init(int _N, int _L, int _X[]){
    N = _N;
    L = _L;
    for (int i = 0; i < N; i++) X[i] = _X[i];

    for (int i = 0; i < N; i++) A[i] = X[i];

    sort(A, A + N);

}

int update(int pos, int val){
    for (int i = 0; i < N; i++){
        if (A[i] == X[pos]) A[i] = val;
    }

    if (X[pos] < val) {
        for (int i = 0; i < N - 1; i++) {
            if (A[i] > A[i + 1]) swap(A[i], A[i + 1]);
        }
    }

    if (X[pos] > val) {
        for (int i = N - 1; i > 1; i--) {
            if (A[i - 1] > A[i]) swap(A[i - 1], A[i]);
        }
    }

    X[pos] = val;

    //for (int i = 0; i < N; i++) cerr << X[i] << ' '; cerr << endl;
    //for (int i = 0; i < N; i++) cerr << A[i] << ' '; cerr << endl << endl;

    int ans = 1, last = A[0];
    for (int i = 0; i < N; i++){
        if (A[i] - last > L){
            ans++;
            last = A[i];
        }
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -