Submission #19146109


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define CREP(i, l, r) for(int i = l; i <= r; i++)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> T; 
typedef pair<ll,ll> P;
typedef vector<int> V;
typedef vector<int> Vll;
const int INF = 1000000000;      //10^9, 2*INF
const ll LLINF = (1LL << 60);   // > 10^18 ll  2*LLINF

int main() {
    int n;
    cin >> n;
    V a(n), b(n); rep(i, n) scanf("%d%d", &a[i],&b[i]);

    vector<P> abb(n);
    rep(i,n){
        abb[i].first = (ll)2*a[i]+b[i];
        abb[i].second = a[i];
    }
    sort(abb.begin(), abb.end());

    ll aok = 0, tkh = 0;
    rep(i,n) aok += a[i];

    int ans = n;
    rep(i,n){
        if(tkh > aok) {
            ans = i;
            break;
        }
        aok -= abb[n-1-i].second;
        tkh += abb[n-1-i].first-abb[n-1-i].second;
    }

    printf("%d\n", ans);
}

Submission Info

Submission Time
Task D - Choose Me
User samari06
Language C++ (GCC 9.2.1)
Score 400
Code Size 930 Byte
Status AC
Exec Time 65 ms
Memory 8072 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   16 |     V a(n), b(n); rep(i, n) scanf("%d%d", &a[i],&b[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01_small.txt, 02_small.txt, 03_small.txt, 04_small.txt, 05_small.txt, 06_small.txt, 07_small.txt, 08_small.txt, 09_small.txt, 10_small.txt, 11_small.txt, 12_small.txt, 13_small.txt, 14_small.txt, 15_small.txt, 16_large.txt, 17_large.txt, 18_large.txt, 19_large.txt, 20_large.txt, 21_large.txt, 22_large.txt, 23_large.txt, 24_large.txt, 25_large.txt, 26_max.txt, 27_max.txt, 28_max.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01_small.txt AC 5 ms 3756 KiB
02_small.txt AC 3 ms 3784 KiB
03_small.txt AC 2 ms 3632 KiB
04_small.txt AC 2 ms 3692 KiB
05_small.txt AC 2 ms 3632 KiB
06_small.txt AC 2 ms 3756 KiB
07_small.txt AC 2 ms 3756 KiB
08_small.txt AC 2 ms 3728 KiB
09_small.txt AC 2 ms 3660 KiB
10_small.txt AC 3 ms 3720 KiB
11_small.txt AC 2 ms 3756 KiB
12_small.txt AC 2 ms 3744 KiB
13_small.txt AC 5 ms 3700 KiB
14_small.txt AC 2 ms 3688 KiB
15_small.txt AC 2 ms 3688 KiB
16_large.txt AC 40 ms 5340 KiB
17_large.txt AC 63 ms 7316 KiB
18_large.txt AC 25 ms 4572 KiB
19_large.txt AC 22 ms 4544 KiB
20_large.txt AC 25 ms 4636 KiB
21_large.txt AC 25 ms 4288 KiB
22_large.txt AC 17 ms 4108 KiB
23_large.txt AC 3 ms 3804 KiB
24_large.txt AC 52 ms 6924 KiB
25_large.txt AC 65 ms 7944 KiB
26_max.txt AC 49 ms 7836 KiB
27_max.txt AC 48 ms 8072 KiB
28_max.txt AC 57 ms 7980 KiB
sample_01.txt AC 2 ms 3784 KiB
sample_02.txt AC 2 ms 3632 KiB
sample_03.txt AC 3 ms 3748 KiB