Submission #136862

# Submission time Handle Problem Language Result Execution time Memory
136862 2019-07-26T11:39:47 Z choikiwon Bodyguards (CEOI10_bodyguards) C++17
50 / 100
504 ms 262148 KB
#include<bits/stdc++.h>
using namespace std;

int R, C;
vector<int> X, Y;

int main() {
    std::ios::sync_with_stdio(false);

    cin >> R;

    for(int i = 0; i < R; i++) {
        int a, b; cin >> a >> b;

        for(int j = 0; j < b; j++) X.push_back(a);
    }

    cin >> C;

    for(int i = 0; i < C; i++) {
        int a, b; cin >> a >> b;

        for(int j = 0; j < b; j++) Y.push_back(a);
    }

    for(int i = 0; i < X.size(); i++) {
        sort(Y.begin(), Y.end());

        if(X[i] > Y.size()) {
            cout << 0;
            return 0;
        }

        for(int j = (int)Y.size() - 1; j >= (int)Y.size() - X[i]; j--) {
            if(!Y[j]) {
                cout << 0;
                return 0;
            }
            Y[j]--;
        }
    }
    for(int i = 0; i < Y.size(); i++) if(Y[i]) {
        cout << 0;
        return 0;
    }

    cout << 1;
}

Compilation message

bodyguards.cpp: In function 'int main()':
bodyguards.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < X.size(); i++) {
                    ~~^~~~~~~~~~
bodyguards.cpp:29:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(X[i] > Y.size()) {
bodyguards.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < Y.size(); i++) if(Y[i]) {
                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 416 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 15 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 380 KB Output is correct
13 Correct 2 ms 404 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
10 Correct 11 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 424 KB Output is correct
13 Correct 8 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 5 ms 392 KB Output is correct
17 Correct 12 ms 376 KB Output is correct
18 Correct 12 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 388 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 13 ms 376 KB Output is correct
6 Correct 10 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 10 ms 376 KB Output is correct
9 Correct 11 ms 404 KB Output is correct
10 Correct 12 ms 376 KB Output is correct
11 Correct 12 ms 376 KB Output is correct
12 Correct 11 ms 476 KB Output is correct
13 Correct 12 ms 376 KB Output is correct
14 Correct 11 ms 376 KB Output is correct
15 Correct 12 ms 376 KB Output is correct
16 Correct 12 ms 376 KB Output is correct
17 Correct 12 ms 376 KB Output is correct
18 Correct 12 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 376 KB Output is correct
2 Correct 29 ms 376 KB Output is correct
3 Correct 26 ms 376 KB Output is correct
4 Correct 29 ms 376 KB Output is correct
5 Correct 23 ms 376 KB Output is correct
6 Correct 25 ms 376 KB Output is correct
7 Correct 23 ms 376 KB Output is correct
8 Correct 26 ms 376 KB Output is correct
9 Correct 32 ms 376 KB Output is correct
10 Correct 32 ms 460 KB Output is correct
11 Correct 32 ms 376 KB Output is correct
12 Correct 32 ms 376 KB Output is correct
13 Correct 32 ms 376 KB Output is correct
14 Correct 25 ms 376 KB Output is correct
15 Correct 32 ms 456 KB Output is correct
16 Correct 25 ms 448 KB Output is correct
17 Correct 32 ms 376 KB Output is correct
18 Correct 26 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 449 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 455 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 504 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 447 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 445 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -