# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
779174 |
2023-07-11T08:41:03 Z |
박영우(#10003) |
Bodyguards (CEOI10_bodyguards) |
C++17 |
|
85 ms |
10896 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 1010101
#define MAXS 22
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#ifdef _MSC_VER
# include <intrin.h>
# define __builtin_popcount __popcnt
#endif
pll arr[MAX];
pll tr[MAX];
pll carr[MAX];
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int R, C;
cin >> R;
int i;
for (i = 1; i <= R; i++) cin >> arr[i].first >> arr[i].second;
sort(arr + 1, arr + R + 1);
reverse(arr + 1, arr + R + 1);
for (i = 1; i <= R; i++) tr[i] = pii(tr[i - 1].first + arr[i].second, arr[i].first - arr[i + 1].first);
sort(tr + 1, tr + R + 1);
reverse(tr + 1, tr + R + 1);
int ptr = 0;
for (i = 1; i <= R; i++) if (tr[i].second) arr[++ptr] = tr[i];
R = ptr;
cin >> C;
for (i = 1; i <= C; i++) cin >> carr[i].first >> carr[i].second;
sort(carr + 1, carr + C + 1);
reverse(carr + 1, carr + C + 1);
vector<ll> v;
for (i = 1; i <= R; i++) arr[i].second += arr[i - 1].second, v.push_back(arr[i].second);
for (i = 1; i <= C; i++) carr[i].second += carr[i - 1].second, v.push_back(carr[i].second);
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
ll pv = 0;
int ptr1, ptr2;
ptr1 = ptr2 = 1;
arr[R + 1].second = carr[C + 1].second = 1e18;
ll sum = 0;
for (auto loc : v) {
while (pv >= arr[ptr1].second) ptr1++;
while (pv >= carr[ptr2].second) ptr2++;
sum += (loc - pv) * arr[ptr1].first;
sum -= (loc - pv) * carr[ptr2].first;
pv = loc;
if (sum < 0) {
cout << 0 << ln;
return 0;
}
}
assert(!sum);
cout << 1 << ln;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 6 |
12 |
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 |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 6 |
15 |
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 |
0 ms |
328 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Runtime error |
2 ms |
576 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Runtime error |
2 ms |
596 KB |
Execution killed with signal 6 |
3 |
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 |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
3372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
7080 KB |
Output is correct |
2 |
Correct |
39 ms |
5276 KB |
Output is correct |
3 |
Correct |
61 ms |
8176 KB |
Output is correct |
4 |
Correct |
9 ms |
1708 KB |
Output is correct |
5 |
Incorrect |
64 ms |
8832 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
10896 KB |
Output is correct |
2 |
Correct |
81 ms |
10720 KB |
Output is correct |
3 |
Correct |
68 ms |
9676 KB |
Output is correct |
4 |
Runtime error |
31 ms |
7660 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |