답안 #778964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
778964 2023-07-11T05:47:17 Z 박상훈(#10000) Bodyguards (CEOI10_bodyguards) C++17
0 / 100
188 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
pair<int, int> a[200200], b[200200];

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

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

	vector<int> X, Y;

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

	scanf("%d", &m);
	for (int i=1;i<=m;i++){
		int x, y;
		scanf("%d %d", &x, &y);
		b[i] = {x, y};
		for (int j=1;j<=y;j++) Y.push_back(x);
	}

	ll cur = 0;
	for (int i=0;i<(int)Y.size();i++){
		cur += Y[i];
		ll val = 0;
		for (int j=0;j<(int)X.size();j++) val += min(X[j], i+1);
		if (cur > val) NO();
	}

	swap(X, Y);
	cur = 0;
	for (int i=0;i<(int)Y.size();i++){
		cur += Y[i];
		ll val = 0;
		for (int j=0;j<(int)X.size();j++) val += min(X[j], i+1);
		if (cur > val) NO();
	}

	printf("1\n");
}

Compilation message

bodyguards.cpp: In function 'int main()':
bodyguards.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  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:25:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  scanf("%d", &m);
      |  ~~~~~^~~~~~~~~~
bodyguards.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 174 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 182 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 174 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 172 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 188 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -