Submission #785907

# Submission time Handle Problem Language Result Execution time Memory
785907 2023-07-17T18:39:27 Z MinaRagy06 Dancing Elephants (IOI11_elephants) C++17
50 / 100
9000 ms 3916 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,O3")
using namespace std;
typedef int64_t ll;

int n, l;
int a[150'005][2];
void init(int N, int L, int X[]) {
    n = N, l = L;
    pair<int, int> v[n];
    for (int i = 0; i < n; i++) {
        v[i] = {X[i], i};
    }
    sort(v, v + n);
    for (int i = 0; i < n; i++) {
        a[i][0] = v[i].first;
        a[i][1] = v[i].second;
    }
}
int update(int x, int y) {
    int pos = -1;
    for (int i = 0; i < n; i++) {
        if (a[i][1] == x) {
            pos = i;
            break;
        }
    }
    if (a[pos][0] < y) {
        a[pos][0] = y;
        for (int i = pos; i + 1 < n && a[i][0] > a[i + 1][0]; i++) {
            swap(a[i][0], a[i + 1][0]);
            swap(a[i][1], a[i + 1][1]);
        }
    } else {
        a[pos][0] = y;
        for (int i = pos; i - 1 >= 0 && a[i][0] < a[i - 1][0]; i--) {
            swap(a[i][0], a[i - 1][0]);
            swap(a[i][1], a[i - 1][1]);
        }
    }
    int prv = a[0][0], cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i][0] - prv > l) {
            cnt++;
            prv = a[i][0];
        }
    }
    return cnt + 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1343 ms 2048 KB Output is correct
8 Correct 2464 ms 2260 KB Output is correct
9 Correct 2669 ms 3428 KB Output is correct
10 Correct 7776 ms 3208 KB Output is correct
11 Correct 7813 ms 3156 KB Output is correct
12 Correct 8464 ms 3300 KB Output is correct
13 Correct 8067 ms 3000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1343 ms 2048 KB Output is correct
8 Correct 2464 ms 2260 KB Output is correct
9 Correct 2669 ms 3428 KB Output is correct
10 Correct 7776 ms 3208 KB Output is correct
11 Correct 7813 ms 3156 KB Output is correct
12 Correct 8464 ms 3300 KB Output is correct
13 Correct 8067 ms 3000 KB Output is correct
14 Correct 2266 ms 3032 KB Output is correct
15 Correct 5025 ms 2996 KB Output is correct
16 Execution timed out 9035 ms 3916 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1343 ms 2048 KB Output is correct
8 Correct 2464 ms 2260 KB Output is correct
9 Correct 2669 ms 3428 KB Output is correct
10 Correct 7776 ms 3208 KB Output is correct
11 Correct 7813 ms 3156 KB Output is correct
12 Correct 8464 ms 3300 KB Output is correct
13 Correct 8067 ms 3000 KB Output is correct
14 Correct 2266 ms 3032 KB Output is correct
15 Correct 5025 ms 2996 KB Output is correct
16 Execution timed out 9035 ms 3916 KB Time limit exceeded
17 Halted 0 ms 0 KB -