# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
779155 |
2023-07-11T08:34:25 Z |
박영우(#10003) |
Bodyguards (CEOI10_bodyguards) |
C++17 |
|
81 ms |
17868 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 + R + 1);
reverse(carr + 1, carr + R + 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 |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
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 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
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 |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
18 ms |
3548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
8048 KB |
Output is correct |
2 |
Correct |
37 ms |
6324 KB |
Output is correct |
3 |
Correct |
51 ms |
7896 KB |
Output is correct |
4 |
Correct |
7 ms |
1624 KB |
Output is correct |
5 |
Incorrect |
62 ms |
8708 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
11264 KB |
Output is correct |
2 |
Correct |
78 ms |
11152 KB |
Output is correct |
3 |
Runtime error |
71 ms |
17868 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |