답안 #1007362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007362 2024-06-24T17:18:50 Z c2zi6 코끼리 (Dancing Elephants) (IOI11_elephants) C++14
26 / 100
9000 ms 10968 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "elephants.h"

int n;
int l;
VI a;
VI b;

void init(int N, int L, int X[]) {
    n = N;
    l = L;
    a = VI(n);
    rep(i, n) a[i] = X[i];
    b = a;
    sort(all(b));
}

stack<int> st;
void replace(VI& b, int x, int y) {
    while (b.back() > x) {
        st.push(b.back());
        b.pop_back();
    }
    b.pop_back();
    while (b.size() && b.back() > y) {
        st.push(b.back());
        b.pop_back();
    }
    while (st.size() && st.top() < y) {
        b.pb(st.top());
        st.pop();
    }
    b.pb(y);
    while (st.size()) {
        b.pb(st.top());
        st.pop();
    }
}

int update(int i, int y) {
    replace(b, a[i], y);
    a[i] = y;
    int R = -1e9;
    int ans = 0;
    for (int x : b) {
        if (x > R) ans++, R = x+l;
    }
    return ans;
}



# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1516 ms 9820 KB Output is correct
8 Correct 2295 ms 9816 KB Output is correct
9 Correct 4805 ms 10968 KB Output is correct
10 Execution timed out 9006 ms 10752 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1516 ms 9820 KB Output is correct
8 Correct 2295 ms 9816 KB Output is correct
9 Correct 4805 ms 10968 KB Output is correct
10 Execution timed out 9006 ms 10752 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1516 ms 9820 KB Output is correct
8 Correct 2295 ms 9816 KB Output is correct
9 Correct 4805 ms 10968 KB Output is correct
10 Execution timed out 9006 ms 10752 KB Time limit exceeded
11 Halted 0 ms 0 KB -