Submission #67723114


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,l,r) for(ll i=l;i<r;i++)
#define ALL(V) V.begin(),V.end()
const ll INF=INT64_MAX/7;
const ll MOD=998244353;
using pll = pair<ll,ll>;
template<class T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> using prique=priority_queue<T,vector<T>,greater<T>>;
#define PRINTRETURN(x) {cout<<x<<endl;return;}
#define PRINTRETURN0(x) {cout<<x<<endl;return 0;}

int main(){
    ll N,M;
    cin>>N>>M;
    // 行動が取れるなら最終状態の本数が多い方が絶対良い
    ll a,b,c;
    vector<tuple<ll,ll,ll>> V(M);
    prique<tuple<ll,ll,ll>> Q;
    rep(i,M){
        cin>>a>>b;
        Q.push({a-b,a,b});
    }
    ll ans=0;
    while(!Q.empty()){
        tie(c,a,b)=Q.top();
        Q.pop();
        if(N<a)continue;
        ll k=(N-a)/c+1;
        N-=c*k;
        ans+=k;
    }
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task D - Get Many Stickers
User confeito
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1093 Byte
Status AC
Exec Time 204 ms
Memory 14240 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3364 KiB
00_sample_01.txt AC 1 ms 3428 KiB
00_sample_02.txt AC 1 ms 3488 KiB
01_random_00.txt AC 92 ms 8516 KiB
01_random_01.txt AC 132 ms 12644 KiB
01_random_02.txt AC 159 ms 13140 KiB
01_random_03.txt AC 95 ms 14036 KiB
01_random_04.txt AC 95 ms 14104 KiB
01_random_05.txt AC 95 ms 14068 KiB
02_random2_00.txt AC 149 ms 14140 KiB
02_random2_01.txt AC 149 ms 14148 KiB
02_random2_02.txt AC 148 ms 14084 KiB
02_random2_03.txt AC 137 ms 14004 KiB
02_random2_04.txt AC 137 ms 14136 KiB
02_random2_05.txt AC 138 ms 14096 KiB
02_random2_06.txt AC 161 ms 14044 KiB
02_random2_07.txt AC 160 ms 14116 KiB
02_random2_08.txt AC 162 ms 14096 KiB
02_random2_09.txt AC 200 ms 14004 KiB
02_random2_10.txt AC 200 ms 14140 KiB
02_random2_11.txt AC 201 ms 14096 KiB
03_random3_00.txt AC 199 ms 14136 KiB
03_random3_01.txt AC 200 ms 14120 KiB
03_random3_02.txt AC 196 ms 14092 KiB
03_random3_03.txt AC 198 ms 14084 KiB
03_random3_04.txt AC 204 ms 14036 KiB
04_handmade_00.txt AC 45 ms 14240 KiB
04_handmade_01.txt AC 46 ms 14036 KiB
04_handmade_02.txt AC 1 ms 3456 KiB
04_handmade_03.txt AC 1 ms 3564 KiB
04_handmade_04.txt AC 200 ms 14096 KiB