Submission #3677227


Source Code Expand

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP0(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define ALL(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	ll a[100],b[100],n,s=0;
	cin >> n;
	REP0(i,n){
		cin >> a[i] >> b[i];
		s+=a[i];
	}
	ll ans=10000000000000000;
	REP0(i,s){
		P mod[100]={};
		ll c[100]={},left=i;
		REP0(j,n){
			mod[j]=P(-(a[j]*i)%s,j);
			left-=(a[j]*i)/s;
			c[j]=(a[j]*i)/s;
		}
		sort(mod,mod+n);
		REP0(j,left) c[mod[j].second]++;
		ll dif=-1;
		REP0(j,n) dif=max(dif,(b[j]-c[j]+a[j]-1)/a[j]);
		ans=min(ans,dif*s+i);
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task E - 選挙
User luogu_bot1
Language C++ (GCC 5.4.1)
Score 200
Code Size 716 Byte
Status AC
Exec Time 562 ms
Memory 256 KB

Judge Result

Set Name Bubunten All
Score / Max Score 50 / 50 150 / 150
Status
AC × 29
AC × 95
Set Name Test Cases
Bubunten small01.txt, small02.txt, small03.txt, small04.txt, small05.txt, small06.txt, small07.txt, small08.txt, small09.txt, small10.txt, small11.txt, small12.txt, small13.txt, small14.txt, small15.txt, small16.txt, small17.txt, small18.txt, small19.txt, small20.txt, small21.txt, small22.txt, small23.txt, small24.txt, small25.txt, sample1.txt, sample2.txt, sample3.txt, 20_minimal.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 20_minimal.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, dekai1.txt, dekai2.txt, sample1.txt, sample2.txt, sample3.txt, small01.txt, small02.txt, small03.txt, small04.txt, small05.txt, small06.txt, small07.txt, small08.txt, small09.txt, small10.txt, small11.txt, small12.txt, small13.txt, small14.txt, small15.txt, small16.txt, small17.txt, small18.txt, small19.txt, small20.txt, small21.txt, small22.txt, small23.txt, small24.txt, small25.txt, yabame1.txt, yabame2.txt, yabame3.txt, yabame4.txt
Case Name Status Exec Time Memory
01.txt AC 318 ms 256 KB
02.txt AC 310 ms 256 KB
03.txt AC 307 ms 256 KB
04.txt AC 331 ms 256 KB
05.txt AC 265 ms 256 KB
06.txt AC 309 ms 256 KB
07.txt AC 319 ms 256 KB
08.txt AC 307 ms 256 KB
09.txt AC 319 ms 256 KB
10.txt AC 320 ms 256 KB
11.txt AC 335 ms 256 KB
12.txt AC 315 ms 256 KB
13.txt AC 285 ms 256 KB
14.txt AC 287 ms 256 KB
15.txt AC 317 ms 256 KB
16.txt AC 311 ms 256 KB
17.txt AC 299 ms 256 KB
18.txt AC 308 ms 256 KB
19.txt AC 265 ms 256 KB
20.txt AC 327 ms 256 KB
20_minimal.txt AC 1 ms 256 KB
21.txt AC 296 ms 256 KB
22.txt AC 313 ms 256 KB
23.txt AC 279 ms 256 KB
24.txt AC 321 ms 256 KB
25.txt AC 294 ms 256 KB
26.txt AC 327 ms 256 KB
27.txt AC 343 ms 256 KB
28.txt AC 307 ms 256 KB
29.txt AC 298 ms 256 KB
30.txt AC 317 ms 256 KB
31.txt AC 307 ms 256 KB
32.txt AC 272 ms 256 KB
33.txt AC 339 ms 256 KB
34.txt AC 293 ms 256 KB
35.txt AC 310 ms 256 KB
36.txt AC 301 ms 256 KB
37.txt AC 295 ms 256 KB
38.txt AC 329 ms 256 KB
39.txt AC 315 ms 256 KB
40.txt AC 293 ms 256 KB
41.txt AC 65 ms 256 KB
42.txt AC 20 ms 256 KB
43.txt AC 3 ms 256 KB
44.txt AC 231 ms 256 KB
45.txt AC 114 ms 256 KB
46.txt AC 52 ms 256 KB
47.txt AC 13 ms 256 KB
48.txt AC 1 ms 256 KB
49.txt AC 196 ms 256 KB
50.txt AC 88 ms 256 KB
51.txt AC 262 ms 256 KB
52.txt AC 312 ms 256 KB
53.txt AC 280 ms 256 KB
54.txt AC 290 ms 256 KB
55.txt AC 281 ms 256 KB
56.txt AC 279 ms 256 KB
57.txt AC 282 ms 256 KB
58.txt AC 316 ms 256 KB
59.txt AC 286 ms 256 KB
60.txt AC 299 ms 256 KB
dekai1.txt AC 407 ms 256 KB
dekai2.txt AC 401 ms 256 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB
small01.txt AC 3 ms 256 KB
small02.txt AC 2 ms 256 KB
small03.txt AC 4 ms 256 KB
small04.txt AC 2 ms 256 KB
small05.txt AC 1 ms 256 KB
small06.txt AC 3 ms 256 KB
small07.txt AC 1 ms 256 KB
small08.txt AC 4 ms 256 KB
small09.txt AC 2 ms 256 KB
small10.txt AC 5 ms 256 KB
small11.txt AC 3 ms 256 KB
small12.txt AC 1 ms 256 KB
small13.txt AC 4 ms 256 KB
small14.txt AC 2 ms 256 KB
small15.txt AC 5 ms 256 KB
small16.txt AC 2 ms 256 KB
small17.txt AC 1 ms 256 KB
small18.txt AC 3 ms 256 KB
small19.txt AC 1 ms 256 KB
small20.txt AC 3 ms 256 KB
small21.txt AC 2 ms 256 KB
small22.txt AC 5 ms 256 KB
small23.txt AC 2 ms 256 KB
small24.txt AC 1 ms 256 KB
small25.txt AC 3 ms 256 KB
yabame1.txt AC 562 ms 256 KB
yabame2.txt AC 559 ms 256 KB
yabame3.txt AC 555 ms 256 KB
yabame4.txt AC 560 ms 256 KB