Submission #779590

# Submission time Handle Problem Language Result Execution time Memory
779590 2023-07-11T14:41:38 Z 79brue Bodyguards (CEOI10_bodyguards) C++17
0 / 100
65 ms 8812 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
pair<ll, ll> a[200002];
pair<ll, ll> b[200002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%lld %lld", &a[i].first, &a[i].second);
    scanf("%d", &m);
    for(int i=1; i<=m; i++) scanf("%lld %lld", &b[i].first, &b[i].second);
    sort(a+1, a+n+1), reverse(a+1, a+n+1);
    sort(b+1, b+m+1), reverse(b+1, b+m+1);

    ll level = 0; /// 초기 시작 위치
    ll limit = m; /// 오른쪽 한계
    ll limitSum = 0;
    ll cur = 0; /// 현재 채운 칸 위치

    for(int i=1; i<=m; i++) limitSum += b[i].second;
    for(int i=1; i<=n; i++){
        ll v = a[i].first * a[i].second;
        while(v){
            if(a[i].first > limitSum){
                puts("0");
                return 0;
            }

            ll tmp = min(v, (b[limit].first - level) * limitSum - cur);
            v -= tmp;
            level += (cur + tmp) / limitSum, cur = (cur + tmp) % limitSum;
            if(b[limit].first<=level) limitSum -= b[limit].second, limit--;
        }
    }

    puts("1");
}

Compilation message

bodyguards.cpp: In function 'int main()':
bodyguards.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bodyguards.cpp:13:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=1; i<=n; i++) scanf("%lld %lld", &a[i].first, &a[i].second);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bodyguards.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
bodyguards.cpp:15:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for(int i=1; i<=m; i++) scanf("%lld %lld", &b[i].first, &b[i].second);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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 312 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 1 ms 312 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 4864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 8812 KB Output is correct
2 Correct 64 ms 8680 KB Output is correct
3 Correct 61 ms 7688 KB Output is correct
4 Incorrect 24 ms 3132 KB Output isn't correct
5 Halted 0 ms 0 KB -