# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136862 | choikiwon | Bodyguards (CEOI10_bodyguards) | C++17 | 504 ms | 262148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |