提出 #67752630


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N;
ll M,a[200000 + 5],b[200000 + 5];
int main () {
    ios::sync_with_stdio (false);
    cin >> N >> M;
    for (int i = 1;i <= M;i ++ ){
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    a[0] = 5000;
    while (1){
        int id = 0;
        for (int i = 1;i <= M;i ++) {
            if (a[i] > N) continue ;       
            if (b[i] * a[id] > a[i] * b[id])
                id = i;
            else if (b[i] * a[id] == a[i] * b[id] && a[i] < a[id]) 
                id = i;
        }
        if (id == 0 || N == 0) {
            ans += N;
            break ;
        }
        while (N >= a[id]) ans += N/a[id]*a[id],N = N%a[id]+N/a[id]*b[id];
    }
    cout << ans ;
    return 0;
}

提出情報

提出日時
問題 G - Get Many Cola
ユーザ whilethan_rp
言語 C++ 20 (gcc 12.2)
得点 0
コード長 793 Byte
結果 WA
実行時間 159 ms
メモリ 6732 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 575
結果
AC × 3
AC × 38
WA × 2
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 02_random2_17.txt, 02_random2_18.txt, 02_random2_19.txt, 02_random2_20.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3612 KiB
00_sample_01.txt AC 1 ms 3412 KiB
00_sample_02.txt AC 1 ms 3396 KiB
01_random_00.txt AC 16 ms 6192 KiB
01_random_01.txt AC 16 ms 6000 KiB
01_random_02.txt AC 16 ms 5344 KiB
01_random_03.txt AC 20 ms 5900 KiB
01_random_04.txt AC 27 ms 6176 KiB
02_random2_00.txt AC 18 ms 6516 KiB
02_random2_01.txt WA 30 ms 6588 KiB
02_random2_02.txt AC 36 ms 6588 KiB
02_random2_03.txt AC 38 ms 6652 KiB
02_random2_04.txt AC 50 ms 6532 KiB
02_random2_05.txt AC 63 ms 6524 KiB
02_random2_06.txt AC 64 ms 6456 KiB
02_random2_07.txt AC 62 ms 6596 KiB
02_random2_08.txt AC 71 ms 6456 KiB
02_random2_09.txt AC 88 ms 6536 KiB
02_random2_10.txt AC 81 ms 6596 KiB
02_random2_11.txt AC 99 ms 6600 KiB
02_random2_12.txt AC 107 ms 6588 KiB
02_random2_13.txt AC 106 ms 6592 KiB
02_random2_14.txt AC 113 ms 6600 KiB
02_random2_15.txt AC 121 ms 6600 KiB
02_random2_16.txt AC 132 ms 6456 KiB
02_random2_17.txt AC 144 ms 6588 KiB
02_random2_18.txt AC 145 ms 6548 KiB
02_random2_19.txt AC 147 ms 6516 KiB
02_random2_20.txt AC 159 ms 6536 KiB
03_random3_00.txt AC 19 ms 6588 KiB
03_random3_01.txt AC 19 ms 6724 KiB
03_random3_02.txt AC 18 ms 6600 KiB
03_random3_03.txt AC 18 ms 6560 KiB
03_random3_04.txt AC 19 ms 6732 KiB
03_random3_05.txt AC 18 ms 6512 KiB
04_handmade_00.txt AC 15 ms 6660 KiB
04_handmade_01.txt AC 15 ms 6544 KiB
04_handmade_02.txt AC 1 ms 3444 KiB
04_handmade_03.txt AC 1 ms 3464 KiB
04_handmade_04.txt WA 18 ms 6584 KiB