답안 #894004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894004 2023-12-27T18:41:49 Z vovik Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
9000 ms 2380 KB
#include <bits/stdc++.h>

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V);

int get(std::vector<int>&a) {
    std::vector<int> x(a.size());
    iota(x.begin(), x.end(), 0);
    stable_sort(x.begin(), x.end(), [&](const int&i, const int&j) { return a[i] < a[j]; });
    int ans = 0;
    for (int i = 0; i < x.size(); ++i) ans = std::max(ans, x[i] - i);
    return ans;
}

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V) {
    int q = X.size();
    std::vector<int> answer(q);
    for (int j = 0; j < q; j++) A[X[j]] = V[j], answer[j] = get(A);
    return answer;
}


#ifdef __APPLE__
#include <cstdio>
#include <cstdlib>
#include <vector>

int readInt() {
    int i;
    if (scanf("%d", &i) != 1) {
        fprintf(stderr, "Error while reading input\n");
        exit(1);
    }
    return i;
}

int main() {
    int N, Q;
    N = readInt();
    Q = readInt();

    std::vector<int> A(N);
    for (int i = 0; i < N; i++)
        A[i] = readInt();

    std::vector<int> X(Q), V(Q);
    for (int j = 0; j < Q; j++) {
        X[j] = readInt();
        V[j] = readInt();
    }

    std::vector<int> res = countScans(A, X, V);

    for (int j = 0; j < int(res.size()); j++)
        printf("%d\n", res[j]);
}
#endif

Compilation message

bubblesort2.cpp: In function 'int get(std::vector<int>&)':
bubblesort2.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < x.size(); ++i) ans = std::max(ans, x[i] - i);
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 600 KB Output is correct
2 Correct 17 ms 348 KB Output is correct
3 Correct 187 ms 480 KB Output is correct
4 Correct 182 ms 348 KB Output is correct
5 Correct 166 ms 484 KB Output is correct
6 Correct 57 ms 344 KB Output is correct
7 Correct 82 ms 344 KB Output is correct
8 Correct 114 ms 484 KB Output is correct
9 Correct 170 ms 484 KB Output is correct
10 Correct 70 ms 348 KB Output is correct
11 Correct 70 ms 344 KB Output is correct
12 Correct 70 ms 348 KB Output is correct
13 Correct 67 ms 348 KB Output is correct
14 Correct 67 ms 344 KB Output is correct
15 Correct 69 ms 348 KB Output is correct
16 Correct 61 ms 480 KB Output is correct
17 Correct 62 ms 344 KB Output is correct
18 Correct 61 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 600 KB Output is correct
2 Correct 17 ms 348 KB Output is correct
3 Correct 187 ms 480 KB Output is correct
4 Correct 182 ms 348 KB Output is correct
5 Correct 166 ms 484 KB Output is correct
6 Correct 57 ms 344 KB Output is correct
7 Correct 82 ms 344 KB Output is correct
8 Correct 114 ms 484 KB Output is correct
9 Correct 170 ms 484 KB Output is correct
10 Correct 70 ms 348 KB Output is correct
11 Correct 70 ms 344 KB Output is correct
12 Correct 70 ms 348 KB Output is correct
13 Correct 67 ms 348 KB Output is correct
14 Correct 67 ms 344 KB Output is correct
15 Correct 69 ms 348 KB Output is correct
16 Correct 61 ms 480 KB Output is correct
17 Correct 62 ms 344 KB Output is correct
18 Correct 61 ms 344 KB Output is correct
19 Correct 3177 ms 644 KB Output is correct
20 Correct 4223 ms 868 KB Output is correct
21 Correct 2376 ms 880 KB Output is correct
22 Correct 3799 ms 868 KB Output is correct
23 Correct 2199 ms 836 KB Output is correct
24 Correct 2262 ms 836 KB Output is correct
25 Correct 2206 ms 836 KB Output is correct
26 Correct 2221 ms 856 KB Output is correct
27 Correct 2249 ms 836 KB Output is correct
28 Correct 2186 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3139 ms 1052 KB Output is correct
2 Execution timed out 9019 ms 2380 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 600 KB Output is correct
2 Correct 17 ms 348 KB Output is correct
3 Correct 187 ms 480 KB Output is correct
4 Correct 182 ms 348 KB Output is correct
5 Correct 166 ms 484 KB Output is correct
6 Correct 57 ms 344 KB Output is correct
7 Correct 82 ms 344 KB Output is correct
8 Correct 114 ms 484 KB Output is correct
9 Correct 170 ms 484 KB Output is correct
10 Correct 70 ms 348 KB Output is correct
11 Correct 70 ms 344 KB Output is correct
12 Correct 70 ms 348 KB Output is correct
13 Correct 67 ms 348 KB Output is correct
14 Correct 67 ms 344 KB Output is correct
15 Correct 69 ms 348 KB Output is correct
16 Correct 61 ms 480 KB Output is correct
17 Correct 62 ms 344 KB Output is correct
18 Correct 61 ms 344 KB Output is correct
19 Correct 3177 ms 644 KB Output is correct
20 Correct 4223 ms 868 KB Output is correct
21 Correct 2376 ms 880 KB Output is correct
22 Correct 3799 ms 868 KB Output is correct
23 Correct 2199 ms 836 KB Output is correct
24 Correct 2262 ms 836 KB Output is correct
25 Correct 2206 ms 836 KB Output is correct
26 Correct 2221 ms 856 KB Output is correct
27 Correct 2249 ms 836 KB Output is correct
28 Correct 2186 ms 828 KB Output is correct
29 Correct 3139 ms 1052 KB Output is correct
30 Execution timed out 9019 ms 2380 KB Time limit exceeded
31 Halted 0 ms 0 KB -