提出 #67759678


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,m;
struct node{
	ll a,b;
	double c;
}d[200005];
bool cmp(node x,node y){
	return x.c<y.c;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>d[i].a>>d[i].b;
		d[i].c=d[i].a/d[i].b;
	}
	sort(d+1,d+m+1,cmp);
	ll ans=0;
	while(1){
		bool f=0;
        //cout<<n<<"\n";
		for(int i=1;i<=m;i++){
			if(d[i].a<=n){
				n-=d[i].a;
				n+=d[i].b;
				ans++;
				f=1;
                break;
			}
		}
		if(f==0){
            break;
        }
	}
	cout<<ans;
	return 0;
}

提出情報

提出日時
問題 D - Get Many Stickers
ユーザ a_little_cat
言語 C++ 20 (gcc 12.2)
得点 0
コード長 572 Byte
結果 WA
実行時間 2210 ms
メモリ 8300 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 3
AC × 7
WA × 4
TLE × 20
セット名 テストケース
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 3492 KiB
00_sample_01.txt AC 1 ms 3600 KiB
00_sample_02.txt AC 1 ms 3472 KiB
01_random_00.txt WA 84 ms 5708 KiB
01_random_01.txt WA 122 ms 6860 KiB
01_random_02.txt WA 142 ms 7260 KiB
01_random_03.txt TLE 2208 ms 8032 KiB
01_random_04.txt TLE 2208 ms 7968 KiB
01_random_05.txt TLE 2207 ms 8028 KiB
02_random2_00.txt TLE 2208 ms 7908 KiB
02_random2_01.txt TLE 2207 ms 8124 KiB
02_random2_02.txt TLE 2207 ms 7968 KiB
02_random2_03.txt WA 821 ms 8136 KiB
02_random2_04.txt TLE 2208 ms 7964 KiB
02_random2_05.txt TLE 2208 ms 7916 KiB
02_random2_06.txt TLE 2207 ms 8124 KiB
02_random2_07.txt TLE 2208 ms 7992 KiB
02_random2_08.txt TLE 2210 ms 7896 KiB
02_random2_09.txt TLE 2208 ms 7932 KiB
02_random2_10.txt TLE 2207 ms 7908 KiB
02_random2_11.txt TLE 2207 ms 7940 KiB
03_random3_00.txt TLE 2208 ms 7896 KiB
03_random3_01.txt TLE 2207 ms 7960 KiB
03_random3_02.txt TLE 2208 ms 7972 KiB
03_random3_03.txt TLE 2208 ms 7996 KiB
03_random3_04.txt TLE 2208 ms 8120 KiB
04_handmade_00.txt AC 43 ms 8284 KiB
04_handmade_01.txt TLE 2210 ms 8056 KiB
04_handmade_02.txt AC 1 ms 3600 KiB
04_handmade_03.txt AC 1 ms 3528 KiB
04_handmade_04.txt AC 169 ms 8300 KiB