Submission #131517

# Submission time Handle Problem Language Result Execution time Memory
131517 2019-07-17T08:34:39 Z sebinkim Bodyguards (CEOI10_bodyguards) C++14
100 / 100
158 ms 7160 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

pll A[202020], B[202020];
ll n, m;

void die() { printf("0\n"); exit(0); }

int main()
{
	ll i, j, s1, s2;
	
	scanf("%lld", &n);
	
	for(i=1; i<=n; i++){
		scanf("%lld%lld", &A[i].first, &A[i].second);
	}
	
	sort(A + 1, A + n + 1);
	
	for(i=n; i>=1; i--){
		A[i].second += A[i + 1].second;
	}
	
	scanf("%lld", &m);
	
	for(i=1; i<=m; i++){
		scanf("%lld%lld", &B[i].first, &B[i].second);
	}
	
	sort(B + 1, B + m + 1);
	reverse(B + 1, B + m + 1);
	
	for(i=1; i<=m; i++){
		B[i].second += B[i - 1].first;
		swap(B[i].first, B[i].second);
	}
	
	for(i=1, j=1, s1=0, s2=0; i<=n; i++){
		for(; j<=m && B[j].first <= A[i].first; j++){
			s2 += (B[j].first - B[j - 1].first) * B[j].second;
			if(s1 + (B[j].first - A[i - 1].first) * A[i].second < s2) die();
		}
		s1 += (A[i].first - A[i - 1].first) * A[i].second;
		if(s1 < s2 + (A[i].first - B[j - 1].first) * B[j].second) die();
	}
	
	printf("1\n");
	
	return 0;
}

Compilation message

bodyguards.cpp: In function 'int main()':
bodyguards.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
bodyguards.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &A[i].first, &A[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bodyguards.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &m);
  ~~~~~^~~~~~~~~~~~
bodyguards.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &B[i].first, &B[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 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 376 KB Output is correct
10 Correct 2 ms 256 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 376 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 256 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 376 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 376 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
17 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 376 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 376 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 376 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
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 424 KB Output is correct
2 Correct 2 ms 376 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 3 ms 376 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 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 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 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
17 Correct 3 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 396 KB Output is correct
2 Correct 2 ms 376 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 376 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 348 KB Output is correct
13 Correct 2 ms 348 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
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 436 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 476 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 6 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 472 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1400 KB Output is correct
2 Correct 20 ms 1160 KB Output is correct
3 Correct 33 ms 1656 KB Output is correct
4 Correct 33 ms 1572 KB Output is correct
5 Correct 34 ms 1636 KB Output is correct
6 Correct 39 ms 1788 KB Output is correct
7 Correct 28 ms 1456 KB Output is correct
8 Correct 39 ms 1912 KB Output is correct
9 Correct 37 ms 1708 KB Output is correct
10 Correct 37 ms 1784 KB Output is correct
11 Correct 37 ms 1784 KB Output is correct
12 Correct 40 ms 1912 KB Output is correct
13 Correct 37 ms 1800 KB Output is correct
14 Correct 38 ms 1912 KB Output is correct
15 Correct 38 ms 1884 KB Output is correct
16 Correct 39 ms 1912 KB Output is correct
17 Correct 39 ms 1928 KB Output is correct
18 Correct 38 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 2680 KB Output is correct
2 Correct 51 ms 2380 KB Output is correct
3 Correct 70 ms 3068 KB Output is correct
4 Correct 11 ms 760 KB Output is correct
5 Correct 80 ms 3448 KB Output is correct
6 Correct 61 ms 2808 KB Output is correct
7 Correct 74 ms 3228 KB Output is correct
8 Correct 12 ms 708 KB Output is correct
9 Correct 80 ms 3580 KB Output is correct
10 Correct 74 ms 3268 KB Output is correct
11 Correct 75 ms 3276 KB Output is correct
12 Correct 75 ms 3192 KB Output is correct
13 Correct 80 ms 3552 KB Output is correct
14 Correct 76 ms 3448 KB Output is correct
15 Correct 77 ms 3504 KB Output is correct
16 Correct 77 ms 3448 KB Output is correct
17 Correct 77 ms 3576 KB Output is correct
18 Correct 77 ms 3552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 4728 KB Output is correct
2 Correct 112 ms 4716 KB Output is correct
3 Correct 97 ms 4148 KB Output is correct
4 Correct 38 ms 1772 KB Output is correct
5 Correct 121 ms 5112 KB Output is correct
6 Correct 107 ms 6964 KB Output is correct
7 Correct 89 ms 4260 KB Output is correct
8 Correct 117 ms 5388 KB Output is correct
9 Correct 144 ms 6392 KB Output is correct
10 Correct 144 ms 6440 KB Output is correct
11 Correct 145 ms 6488 KB Output is correct
12 Correct 145 ms 6344 KB Output is correct
13 Correct 144 ms 6520 KB Output is correct
14 Correct 16 ms 1272 KB Output is correct
15 Correct 158 ms 7016 KB Output is correct
16 Correct 158 ms 7160 KB Output is correct
17 Correct 158 ms 7004 KB Output is correct
18 Correct 145 ms 6400 KB Output is correct