Submission #778941

# Submission time Handle Problem Language Result Execution time Memory
778941 2023-07-11T04:16:03 Z 박상훈(#10000) Bodyguards (CEOI10_bodyguards) C++17
50 / 100
227 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

int main(){
	int n, m;
	scanf("%d", &n);

	vector<int> V;
	priority_queue<int> pq;

	for (int i=1;i<=n;i++){
		int x, y;
		scanf("%d %d", &x, &y);
		for (int j=1;j<=y;j++) V.push_back(x);
	}

	scanf("%d", &m);
	for (int i=1;i<=m;i++){
		int x, y;
		scanf("%d %d", &x, &y);
		for (int j=1;j<=y;j++) pq.push(x);
	}

	for (auto &x:V){
		if ((int)pq.size() < x) NO();
		vector<int> tmp;
		
		for (int i=0;i<x;i++){
			tmp.push_back(pq.top()); pq.pop();
		}

		for (auto &y:tmp) if (y>1) pq.push(y-1);
	}

	printf("1\n");
}

Compilation message

bodyguards.cpp: In function 'int main()':
bodyguards.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
bodyguards.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
bodyguards.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d", &m);
      |  ~~~~~^~~~~~~~~~
bodyguards.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 296 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 212 KB Output is correct
2 Correct 6 ms 212 KB Output is correct
3 Correct 5 ms 212 KB Output is correct
4 Correct 6 ms 304 KB Output is correct
5 Correct 4 ms 304 KB Output is correct
6 Correct 4 ms 212 KB Output is correct
7 Correct 7 ms 300 KB Output is correct
8 Correct 5 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 5 ms 304 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 5 ms 340 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 4 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 316 KB Output is correct
2 Correct 28 ms 212 KB Output is correct
3 Correct 31 ms 300 KB Output is correct
4 Correct 22 ms 212 KB Output is correct
5 Correct 43 ms 308 KB Output is correct
6 Correct 29 ms 212 KB Output is correct
7 Correct 34 ms 212 KB Output is correct
8 Correct 14 ms 320 KB Output is correct
9 Correct 18 ms 320 KB Output is correct
10 Correct 21 ms 320 KB Output is correct
11 Correct 19 ms 212 KB Output is correct
12 Correct 20 ms 316 KB Output is correct
13 Correct 20 ms 212 KB Output is correct
14 Correct 18 ms 320 KB Output is correct
15 Correct 19 ms 320 KB Output is correct
16 Correct 20 ms 304 KB Output is correct
17 Correct 19 ms 324 KB Output is correct
18 Correct 19 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 332 KB Output is correct
2 Correct 47 ms 340 KB Output is correct
3 Correct 44 ms 308 KB Output is correct
4 Correct 46 ms 320 KB Output is correct
5 Correct 43 ms 312 KB Output is correct
6 Correct 45 ms 340 KB Output is correct
7 Correct 44 ms 316 KB Output is correct
8 Correct 46 ms 340 KB Output is correct
9 Correct 59 ms 340 KB Output is correct
10 Correct 58 ms 340 KB Output is correct
11 Correct 58 ms 340 KB Output is correct
12 Correct 59 ms 320 KB Output is correct
13 Correct 58 ms 340 KB Output is correct
14 Correct 57 ms 212 KB Output is correct
15 Correct 58 ms 340 KB Output is correct
16 Correct 55 ms 212 KB Output is correct
17 Correct 58 ms 320 KB Output is correct
18 Correct 59 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 209 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 227 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 174 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 175 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -