提出 #68214524


ソースコード 拡げる

//Author: NguyenBaoAnh
#include <bits/stdc++.h>
using namespace std;
void init() {
    //freopen("trammang.inp", "r", stdin), freopen("trammang.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}
#define int long long
#define db double
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
const int N=2e5, M=1e5, mod=1e9+7, B=450;
int m, n;
ii a[N+5];
bool cmp(ii a, ii b) {
    int x=a.fi-a.se, y=b.fi-b.se;
    if(x!=y) return x<y;
    return a.fi>b.fi;
}
void solve() {
    cin>>m>>n;
    for(int i=1; i<=n; i++) cin>>a[i].fi>>a[i].se;
    sort(a+1,a+n+1,cmp);
    int kq=0;
    for(int i=1; i<=n; i++) {
        if(m<a[i].fi) continue;
        int dec=a[i].fi-a[i].se, sl=(m-a[i].fi)/dec+1;
        kq+=sl; m-=sl*dec;
    }
    cout<<kq<<'\n';
}
main()
{
    init();
    int Q=1; //cin>>Q;
    while(Q--) solve();
    return 0;
}

提出情報

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

コンパイルエラー

Main.cpp:34:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   34 | main()
      | ^~~~

ジャッジ結果

セット名 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 2 ms 3384 KiB
00_sample_01.txt AC 1 ms 3492 KiB
00_sample_02.txt AC 1 ms 3492 KiB
01_random_00.txt AC 24 ms 4892 KiB
01_random_01.txt AC 34 ms 5556 KiB
01_random_02.txt AC 42 ms 6120 KiB
01_random_03.txt AC 37 ms 6576 KiB
01_random_04.txt AC 36 ms 6480 KiB
01_random_05.txt AC 37 ms 6592 KiB
02_random2_00.txt AC 46 ms 6572 KiB
02_random2_01.txt AC 47 ms 6480 KiB
02_random2_02.txt AC 47 ms 6612 KiB
02_random2_03.txt AC 45 ms 6536 KiB
02_random2_04.txt AC 45 ms 6744 KiB
02_random2_05.txt AC 45 ms 6604 KiB
02_random2_06.txt AC 48 ms 6540 KiB
02_random2_07.txt AC 47 ms 6552 KiB
02_random2_08.txt AC 47 ms 6508 KiB
02_random2_09.txt AC 50 ms 6744 KiB
02_random2_10.txt AC 51 ms 6496 KiB
02_random2_11.txt AC 50 ms 6536 KiB
03_random3_00.txt AC 60 ms 6744 KiB
03_random3_01.txt AC 51 ms 6620 KiB
03_random3_02.txt AC 50 ms 6576 KiB
03_random3_03.txt AC 50 ms 6556 KiB
03_random3_04.txt AC 51 ms 6616 KiB
04_handmade_00.txt AC 20 ms 6596 KiB
04_handmade_01.txt AC 19 ms 6680 KiB
04_handmade_02.txt AC 1 ms 3432 KiB
04_handmade_03.txt AC 1 ms 3500 KiB
04_handmade_04.txt AC 52 ms 6616 KiB