답안 #131497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131497 2019-07-17T08:18:55 Z sebinkim Bodyguards (CEOI10_bodyguards) C++14
0 / 100
116 ms 4840 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, s;
	
	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].first;
    }
	
	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].second + B[i].first * B[i].second;
    }
	
	for(i=1, j=1, s=0; i<=n; i++){
		for(; j<=m && B[j].first <= A[i].first; j++){
			if(s + (B[j].first - A[i - 1].first) * A[i].second < B[j].second) die();
		}
		s += (A[i].first - A[i - 1].first) * A[i].second;
    }
	
	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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 2744 KB Output is correct
2 Incorrect 52 ms 2424 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 4840 KB Output is correct
2 Correct 112 ms 4724 KB Output is correct
3 Incorrect 104 ms 4148 KB Output isn't correct
4 Halted 0 ms 0 KB -