結果

問題 No.761 平均値ゲーム
ユーザー tentententen
提出日時 2023-06-16 13:13:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 2,452 bytes
コンパイル時間 2,702 ms
コンパイル使用メモリ 87,544 KB
実行使用メモリ 59,956 KB
最終ジャッジ日時 2023-09-06 12:24:55
合計ジャッジ時間 21,859 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,776 KB
testcase_01 AC 44 ms
49,544 KB
testcase_02 AC 44 ms
49,432 KB
testcase_03 AC 45 ms
49,704 KB
testcase_04 AC 44 ms
49,892 KB
testcase_05 AC 45 ms
49,688 KB
testcase_06 AC 44 ms
49,468 KB
testcase_07 AC 45 ms
50,020 KB
testcase_08 AC 44 ms
49,396 KB
testcase_09 AC 45 ms
49,432 KB
testcase_10 AC 45 ms
49,380 KB
testcase_11 AC 44 ms
49,420 KB
testcase_12 AC 45 ms
49,348 KB
testcase_13 AC 44 ms
47,456 KB
testcase_14 AC 45 ms
49,620 KB
testcase_15 AC 44 ms
49,380 KB
testcase_16 AC 44 ms
49,348 KB
testcase_17 AC 44 ms
49,528 KB
testcase_18 AC 44 ms
49,520 KB
testcase_19 AC 45 ms
49,436 KB
testcase_20 AC 44 ms
49,436 KB
testcase_21 AC 44 ms
49,528 KB
testcase_22 AC 44 ms
49,368 KB
testcase_23 AC 45 ms
49,888 KB
testcase_24 AC 45 ms
49,516 KB
testcase_25 AC 45 ms
49,436 KB
testcase_26 AC 45 ms
49,368 KB
testcase_27 AC 45 ms
49,372 KB
testcase_28 AC 45 ms
49,416 KB
testcase_29 AC 45 ms
49,712 KB
testcase_30 AC 44 ms
49,548 KB
testcase_31 AC 45 ms
49,704 KB
testcase_32 AC 44 ms
49,604 KB
testcase_33 AC 206 ms
57,628 KB
testcase_34 AC 213 ms
57,496 KB
testcase_35 AC 105 ms
52,512 KB
testcase_36 AC 185 ms
56,032 KB
testcase_37 AC 189 ms
57,428 KB
testcase_38 AC 206 ms
57,604 KB
testcase_39 AC 214 ms
57,676 KB
testcase_40 AC 210 ms
57,548 KB
testcase_41 AC 210 ms
57,444 KB
testcase_42 AC 225 ms
58,004 KB
testcase_43 AC 130 ms
55,380 KB
testcase_44 AC 204 ms
55,900 KB
testcase_45 AC 209 ms
57,212 KB
testcase_46 AC 192 ms
56,028 KB
testcase_47 AC 194 ms
55,768 KB
testcase_48 AC 93 ms
52,076 KB
testcase_49 AC 217 ms
57,876 KB
testcase_50 AC 110 ms
52,844 KB
testcase_51 AC 103 ms
53,876 KB
testcase_52 AC 94 ms
52,108 KB
testcase_53 AC 217 ms
57,520 KB
testcase_54 AC 171 ms
55,588 KB
testcase_55 AC 213 ms
57,852 KB
testcase_56 AC 154 ms
55,436 KB
testcase_57 AC 220 ms
55,664 KB
testcase_58 AC 128 ms
54,652 KB
testcase_59 AC 209 ms
57,336 KB
testcase_60 AC 144 ms
54,636 KB
testcase_61 AC 223 ms
59,804 KB
testcase_62 AC 213 ms
57,728 KB
testcase_63 AC 136 ms
55,304 KB
testcase_64 AC 206 ms
57,388 KB
testcase_65 AC 161 ms
55,304 KB
testcase_66 AC 103 ms
52,716 KB
testcase_67 AC 152 ms
55,388 KB
testcase_68 AC 111 ms
54,128 KB
testcase_69 AC 212 ms
57,304 KB
testcase_70 AC 172 ms
55,280 KB
testcase_71 AC 143 ms
54,944 KB
testcase_72 AC 113 ms
52,680 KB
testcase_73 AC 155 ms
55,160 KB
testcase_74 AC 135 ms
54,856 KB
testcase_75 AC 190 ms
55,688 KB
testcase_76 AC 145 ms
55,452 KB
testcase_77 AC 201 ms
56,136 KB
testcase_78 AC 186 ms
56,100 KB
testcase_79 AC 135 ms
55,268 KB
testcase_80 AC 125 ms
53,076 KB
testcase_81 AC 118 ms
52,704 KB
testcase_82 AC 201 ms
57,824 KB
testcase_83 AC 226 ms
59,956 KB
testcase_84 AC 225 ms
59,672 KB
testcase_85 AC 225 ms
57,920 KB
testcase_86 AC 228 ms
59,868 KB
testcase_87 AC 231 ms
59,828 KB
testcase_88 AC 229 ms
59,728 KB
testcase_89 AC 228 ms
59,488 KB
testcase_90 AC 227 ms
59,800 KB
testcase_91 AC 229 ms
59,692 KB
testcase_92 AC 229 ms
59,524 KB
testcase_93 AC 46 ms
49,420 KB
testcase_94 AC 45 ms
49,496 KB
testcase_95 AC 213 ms
59,524 KB
testcase_96 AC 219 ms
59,748 KB
testcase_97 AC 229 ms
59,888 KB
testcase_98 AC 181 ms
57,228 KB
testcase_99 AC 230 ms
59,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    static long[] values;
    static long[] sums;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        values = new long[n + 1];
        sums = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            values[i] = sc.nextLong();
            sums[i] = sums[i - 1] + values[i];
        }
        if (getTF(0, n)) {
            System.out.println("First");
        } else {
            System.out.println("Second");
        }
    }
    
    static boolean getTF(int start, int end) {
        if (end - start == 1) {
            return true;
        }
        if (values[end] * (end - start) == sums[end] - sums[start]) {
            return true;
        }
        double avg = (double)(sums[end] - sums[start]) / (end - start);
        int left = start;
        int right = end;
        while (right - left > 1) {
            int m = (left + right) / 2;
            if (values[m] >= avg) {
                right = m;
            } else {
                left = m;
            }
        }
        return !(getTF(start, left) && getTF(left, end));
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0