結果

問題 No.761 平均値ゲーム
ユーザー iicafiaxusiicafiaxus
提出日時 2018-12-09 03:27:49
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 116,000 KB
実行使用メモリ 9,260 KB
最終ジャッジ日時 2023-09-03 21:28:24
合計ジャッジ時間 5,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 22 ms
6,184 KB
testcase_34 AC 25 ms
6,736 KB
testcase_35 AC 4 ms
4,384 KB
testcase_36 AC 15 ms
5,648 KB
testcase_37 AC 20 ms
5,964 KB
testcase_38 AC 20 ms
5,768 KB
testcase_39 AC 26 ms
6,760 KB
testcase_40 AC 26 ms
6,568 KB
testcase_41 AC 25 ms
6,488 KB
testcase_42 AC 27 ms
7,200 KB
testcase_43 AC 6 ms
4,380 KB
testcase_44 AC 17 ms
6,352 KB
testcase_45 AC 23 ms
6,684 KB
testcase_46 AC 14 ms
4,704 KB
testcase_47 AC 14 ms
5,656 KB
testcase_48 AC 3 ms
4,376 KB
testcase_49 AC 28 ms
7,464 KB
testcase_50 AC 5 ms
4,376 KB
testcase_51 AC 3 ms
4,384 KB
testcase_52 AC 4 ms
4,380 KB
testcase_53 AC 28 ms
7,528 KB
testcase_54 AC 16 ms
5,908 KB
testcase_55 AC 29 ms
7,468 KB
testcase_56 AC 9 ms
5,148 KB
testcase_57 AC 28 ms
7,328 KB
testcase_58 AC 5 ms
4,380 KB
testcase_59 AC 25 ms
6,612 KB
testcase_60 AC 9 ms
5,168 KB
testcase_61 AC 30 ms
7,524 KB
testcase_62 AC 27 ms
7,404 KB
testcase_63 AC 7 ms
4,380 KB
testcase_64 AC 24 ms
6,376 KB
testcase_65 AC 11 ms
6,124 KB
testcase_66 AC 4 ms
4,380 KB
testcase_67 AC 9 ms
5,432 KB
testcase_68 AC 4 ms
4,380 KB
testcase_69 AC 21 ms
5,976 KB
testcase_70 AC 14 ms
5,676 KB
testcase_71 AC 8 ms
4,376 KB
testcase_72 AC 4 ms
4,380 KB
testcase_73 AC 10 ms
4,384 KB
testcase_74 AC 7 ms
4,376 KB
testcase_75 AC 14 ms
5,696 KB
testcase_76 AC 9 ms
4,380 KB
testcase_77 AC 21 ms
6,312 KB
testcase_78 AC 15 ms
5,756 KB
testcase_79 AC 6 ms
5,332 KB
testcase_80 AC 5 ms
4,380 KB
testcase_81 AC 4 ms
4,380 KB
testcase_82 AC 19 ms
6,416 KB
testcase_83 AC 31 ms
7,760 KB
testcase_84 AC 31 ms
7,620 KB
testcase_85 AC 31 ms
7,540 KB
testcase_86 AC 31 ms
7,720 KB
testcase_87 AC 31 ms
7,572 KB
testcase_88 AC 31 ms
7,684 KB
testcase_89 AC 31 ms
7,532 KB
testcase_90 AC 31 ms
7,640 KB
testcase_91 AC 31 ms
9,116 KB
testcase_92 AC 30 ms
9,100 KB
testcase_93 AC 1 ms
4,376 KB
testcase_94 AC 1 ms
4,380 KB
testcase_95 AC 29 ms
7,564 KB
testcase_96 AC 31 ms
9,260 KB
testcase_97 AC 30 ms
7,676 KB
testcase_98 AC 20 ms
6,604 KB
testcase_99 AC 31 ms
7,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int n;
long[] as;
long[] sums; // sums[i] は as[i -1] までの和
void main(){
	n = read.to!int;
	as = readln.chomp.split.map!(to!long).array;
	
	sums = [0];
	foreach(a; as) sums ~= sums[$ - 1] + a;
	
	solve(0, n - 1).writeln;
}

string solve(int l, int r){ // [l, r]
	int c = uplimit(l, r, (int i) => as[i] * (r + 1 - l) < sums[r + 1] - sums[l]);
	if(c < l) return "First";
	else if(solve(l, c) == "Second") return "First";
	else if(solve(c + 1, r) == "Second") return "First";
	else return "Second";
}

// fをみたす最大
int uplimit(int a, int c, bool delegate(int) f){
	if(f(c)) return c;
	if(! f(a)) return a - 1;
	while(a + 1 < c){
		int b = (a + c) / 2;
		if(f(b)) a = b;
		else c = b;
	}
	return a;
}
0