提出 #57416


ソースコード 拡げる

#include<cstdio>
#include<algorithm>
#include<string>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,int> P;

const int MX = 105;
const ll INF = 100000000005ll;

int n, s, a[MX], b[MX];
ll z[MX];
P p[MX];

bool f(ll x){
	ll sum = x;
	rep(i,n){
		z[i] = x*a[i]/s;
		p[i] = P(-(x*a[i]-z[i]*s),i);
		sum -= z[i];
	}
	sort(p,p+n);
	
	rep(j,n){
		int i = p[j].se;
		if(z[i]+(j<sum?1:0) < b[i]) return false;
	}
	return true;
}

int main(){
	ll l = 0, r = INF, c;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&a[i],&b[i]);
		s += a[i];
	}
	
	while(l+1<r){
		c = (l+r)/2;
		if(f(c)) r = c; else l = c;
	}
	
	printf("%lld\n",r);
	
	return 0;
}

提出情報

提出日時
問題 E - 選挙
ユーザ UTPerorinC
言語 C++ (G++ 4.6.4)
得点 0
コード長 824 Byte
結果 WA
実行時間 27 ms
メモリ 692 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:39:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

ジャッジ結果

セット名 Bubunten All
得点 / 配点 0 / 50 0 / 150
結果
AC × 14
WA × 15
AC × 15
WA × 77
セット名 テストケース
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, 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
ケース名 結果 実行時間 メモリ
01.txt WA 19 ms 636 KiB
02.txt WA 18 ms 660 KiB
03.txt WA 19 ms 660 KiB
04.txt AC 19 ms 656 KiB
05.txt WA 19 ms 664 KiB
06.txt WA 19 ms 580 KiB
07.txt WA 17 ms 660 KiB
08.txt WA 17 ms 656 KiB
09.txt WA 18 ms 664 KiB
10.txt WA 18 ms 656 KiB
11.txt WA 18 ms 664 KiB
12.txt WA 18 ms 656 KiB
13.txt WA 18 ms 660 KiB
14.txt WA 18 ms 652 KiB
15.txt WA 19 ms 656 KiB
16.txt WA 18 ms 660 KiB
17.txt WA 17 ms 656 KiB
18.txt WA 18 ms 692 KiB
19.txt WA 18 ms 660 KiB
20.txt WA 18 ms 660 KiB
20_minimal.txt AC 17 ms 632 KiB
21.txt WA 17 ms 664 KiB
22.txt WA 18 ms 660 KiB
23.txt WA 19 ms 660 KiB
24.txt WA 18 ms 656 KiB
25.txt AC 19 ms 660 KiB
26.txt WA 19 ms 684 KiB
27.txt WA 18 ms 660 KiB
28.txt WA 19 ms 660 KiB
29.txt WA 19 ms 688 KiB
30.txt WA 19 ms 660 KiB
31.txt WA 27 ms 664 KiB
32.txt WA 18 ms 656 KiB
33.txt AC 18 ms 660 KiB
34.txt WA 18 ms 656 KiB
35.txt WA 18 ms 656 KiB
36.txt WA 18 ms 656 KiB
37.txt WA 18 ms 648 KiB
38.txt WA 17 ms 680 KiB
39.txt WA 18 ms 652 KiB
40.txt WA 19 ms 660 KiB
41.txt WA 18 ms 660 KiB
42.txt WA 18 ms 664 KiB
43.txt WA 17 ms 656 KiB
44.txt WA 17 ms 684 KiB
45.txt WA 18 ms 644 KiB
46.txt WA 18 ms 656 KiB
47.txt WA 18 ms 664 KiB
48.txt AC 18 ms 660 KiB
49.txt WA 18 ms 656 KiB
50.txt WA 18 ms 684 KiB
51.txt WA 18 ms 656 KiB
52.txt WA 18 ms 688 KiB
53.txt WA 18 ms 656 KiB
54.txt WA 23 ms 680 KiB
55.txt WA 18 ms 652 KiB
56.txt WA 18 ms 656 KiB
57.txt WA 18 ms 632 KiB
58.txt WA 18 ms 664 KiB
59.txt WA 18 ms 664 KiB
60.txt WA 19 ms 652 KiB
dekai1.txt WA 18 ms 688 KiB
dekai2.txt WA 19 ms 664 KiB
sample1.txt AC 18 ms 660 KiB
sample2.txt AC 21 ms 652 KiB
sample3.txt AC 17 ms 656 KiB
small01.txt WA 18 ms 660 KiB
small02.txt AC 18 ms 664 KiB
small03.txt WA 18 ms 652 KiB
small04.txt WA 17 ms 656 KiB
small05.txt AC 18 ms 656 KiB
small06.txt AC 18 ms 656 KiB
small07.txt AC 18 ms 656 KiB
small08.txt WA 18 ms 656 KiB
small09.txt WA 18 ms 664 KiB
small10.txt AC 17 ms 656 KiB
small11.txt WA 18 ms 656 KiB
small12.txt WA 18 ms 656 KiB
small13.txt WA 18 ms 652 KiB
small14.txt AC 18 ms 692 KiB
small15.txt WA 18 ms 656 KiB
small16.txt WA 18 ms 660 KiB
small17.txt AC 18 ms 636 KiB
small18.txt AC 18 ms 660 KiB
small19.txt WA 17 ms 660 KiB
small20.txt WA 18 ms 656 KiB
small21.txt WA 18 ms 660 KiB
small22.txt WA 18 ms 684 KiB
small23.txt AC 18 ms 684 KiB
small24.txt AC 18 ms 656 KiB
small25.txt WA 18 ms 660 KiB
yabame1.txt WA 18 ms 660 KiB
yabame2.txt WA 18 ms 640 KiB
yabame3.txt WA 19 ms 656 KiB
yabame4.txt WA 18 ms 644 KiB