提出 #67721400


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s); i <= (t); i ++)
#define per(i, s, t) for(int i = (s); i >= (t); i --)
template<typename T, typename T2>
inline void chmin(T &x, T2 &&y) { x = min(x, y); }
template<typename T, typename T2>
inline void chmax(T &x, T2 &&y) { x = max(x, y); }
typedef long long ll;

const int N = 2e5 + 5;
ll n, a[N], b[N];
int id[N], m;

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> m;
    rep(i, 1, m) cin >> a[i] >> b[i], b[i] = a[i] - b[i], id[i] = i;
    sort(id + 1, id + m + 1, [](int x, int y) { 
        return b[x] == b[y] ? a[x] < a[y] : b[x] < b[y];
    });
    ll ans = 0;
    rep(o, 1, m)
    {
        int i = id[o];
        if(n >= a[i])
        {
            ans += (n - a[i]) / b[i] + 1;
            n = (n - a[i]) % b[i] + a[i] - b[i];
        }
    }
    cout << ans;

    return 0;
}

提出情報

提出日時
問題 D - Get Many Stickers
ユーザ kr_vcf
言語 C++ 20 (gcc 12.2)
得点 400
コード長 929 Byte
結果 AC
実行時間 57 ms
メモリ 7432 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 31
セット名 テストケース
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, 01_random_05.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, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.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 3476 KiB
00_sample_01.txt AC 1 ms 3452 KiB
00_sample_02.txt AC 1 ms 3536 KiB
01_random_00.txt AC 25 ms 5356 KiB
01_random_01.txt AC 36 ms 6132 KiB
01_random_02.txt AC 43 ms 6684 KiB
01_random_03.txt AC 41 ms 7428 KiB
01_random_04.txt AC 42 ms 7228 KiB
01_random_05.txt AC 41 ms 7296 KiB
02_random2_00.txt AC 49 ms 7236 KiB
02_random2_01.txt AC 49 ms 7328 KiB
02_random2_02.txt AC 50 ms 7432 KiB
02_random2_03.txt AC 48 ms 7364 KiB
02_random2_04.txt AC 48 ms 7312 KiB
02_random2_05.txt AC 47 ms 7348 KiB
02_random2_06.txt AC 50 ms 7372 KiB
02_random2_07.txt AC 50 ms 7360 KiB
02_random2_08.txt AC 50 ms 7380 KiB
02_random2_09.txt AC 53 ms 7296 KiB
02_random2_10.txt AC 53 ms 7232 KiB
02_random2_11.txt AC 53 ms 7360 KiB
03_random3_00.txt AC 57 ms 7364 KiB
03_random3_01.txt AC 55 ms 7292 KiB
03_random3_02.txt AC 53 ms 7300 KiB
03_random3_03.txt AC 52 ms 7316 KiB
03_random3_04.txt AC 52 ms 7320 KiB
04_handmade_00.txt AC 16 ms 7372 KiB
04_handmade_01.txt AC 16 ms 7360 KiB
04_handmade_02.txt AC 1 ms 3540 KiB
04_handmade_03.txt AC 1 ms 3476 KiB
04_handmade_04.txt AC 55 ms 7376 KiB