답안 #224812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224812 2020-04-18T22:34:37 Z Bruteforceman Bubble Sort 2 (JOI18_bubblesort2) C++11
38 / 100
9000 ms 2428 KB
#include "bits/stdc++.h"
#include "bubblesort2.h"
using namespace std;

int solve(vector <int> &A) {
    vector <int> cmp (A.size()), pos (A.size());
    for(int i = 0; i < A.size(); i++) cmp[i] = i;
    stable_sort(cmp.begin(), cmp.end(), [&] (int i, int j) { return A[i] < A[j]; });
    for(int i = 0; i < A.size(); i++) pos[cmp[i]] = i;
    int ans = 0;
    for(int i = 0; i < A.size(); i++) {
        ans = max(ans, i - pos[i]);
    }
    return ans;
}

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

Compilation message

bubblesort2.cpp: In function 'int solve(std::vector<int>&)':
bubblesort2.cpp:7:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) cmp[i] = i;
                    ~~^~~~~~~~~~
bubblesort2.cpp:9:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) pos[cmp[i]] = i;
                    ~~^~~~~~~~~~
bubblesort2.cpp:11:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) {
                    ~~^~~~~~~~~~
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:19:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < X.size(); i++) {
                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 33 ms 384 KB Output is correct
3 Correct 231 ms 384 KB Output is correct
4 Correct 229 ms 512 KB Output is correct
5 Correct 216 ms 384 KB Output is correct
6 Correct 107 ms 384 KB Output is correct
7 Correct 145 ms 436 KB Output is correct
8 Correct 177 ms 384 KB Output is correct
9 Correct 218 ms 504 KB Output is correct
10 Correct 124 ms 504 KB Output is correct
11 Correct 125 ms 384 KB Output is correct
12 Correct 124 ms 384 KB Output is correct
13 Correct 121 ms 504 KB Output is correct
14 Correct 121 ms 444 KB Output is correct
15 Correct 121 ms 384 KB Output is correct
16 Correct 118 ms 384 KB Output is correct
17 Correct 121 ms 384 KB Output is correct
18 Correct 121 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 33 ms 384 KB Output is correct
3 Correct 231 ms 384 KB Output is correct
4 Correct 229 ms 512 KB Output is correct
5 Correct 216 ms 384 KB Output is correct
6 Correct 107 ms 384 KB Output is correct
7 Correct 145 ms 436 KB Output is correct
8 Correct 177 ms 384 KB Output is correct
9 Correct 218 ms 504 KB Output is correct
10 Correct 124 ms 504 KB Output is correct
11 Correct 125 ms 384 KB Output is correct
12 Correct 124 ms 384 KB Output is correct
13 Correct 121 ms 504 KB Output is correct
14 Correct 121 ms 444 KB Output is correct
15 Correct 121 ms 384 KB Output is correct
16 Correct 118 ms 384 KB Output is correct
17 Correct 121 ms 384 KB Output is correct
18 Correct 121 ms 384 KB Output is correct
19 Correct 4113 ms 736 KB Output is correct
20 Correct 5392 ms 640 KB Output is correct
21 Correct 3063 ms 736 KB Output is correct
22 Correct 4962 ms 664 KB Output is correct
23 Correct 2842 ms 656 KB Output is correct
24 Correct 2850 ms 736 KB Output is correct
25 Correct 2832 ms 664 KB Output is correct
26 Correct 2849 ms 656 KB Output is correct
27 Correct 2855 ms 656 KB Output is correct
28 Correct 2858 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4307 ms 1244 KB Output is correct
2 Execution timed out 9017 ms 2428 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 33 ms 384 KB Output is correct
3 Correct 231 ms 384 KB Output is correct
4 Correct 229 ms 512 KB Output is correct
5 Correct 216 ms 384 KB Output is correct
6 Correct 107 ms 384 KB Output is correct
7 Correct 145 ms 436 KB Output is correct
8 Correct 177 ms 384 KB Output is correct
9 Correct 218 ms 504 KB Output is correct
10 Correct 124 ms 504 KB Output is correct
11 Correct 125 ms 384 KB Output is correct
12 Correct 124 ms 384 KB Output is correct
13 Correct 121 ms 504 KB Output is correct
14 Correct 121 ms 444 KB Output is correct
15 Correct 121 ms 384 KB Output is correct
16 Correct 118 ms 384 KB Output is correct
17 Correct 121 ms 384 KB Output is correct
18 Correct 121 ms 384 KB Output is correct
19 Correct 4113 ms 736 KB Output is correct
20 Correct 5392 ms 640 KB Output is correct
21 Correct 3063 ms 736 KB Output is correct
22 Correct 4962 ms 664 KB Output is correct
23 Correct 2842 ms 656 KB Output is correct
24 Correct 2850 ms 736 KB Output is correct
25 Correct 2832 ms 664 KB Output is correct
26 Correct 2849 ms 656 KB Output is correct
27 Correct 2855 ms 656 KB Output is correct
28 Correct 2858 ms 660 KB Output is correct
29 Correct 4307 ms 1244 KB Output is correct
30 Execution timed out 9017 ms 2428 KB Time limit exceeded
31 Halted 0 ms 0 KB -