結果

問題 No.761 平均値ゲーム
ユーザー hiromi_ayasehiromi_ayase
提出日時 2018-12-09 02:29:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 3,211 bytes
コンパイル時間 3,196 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 48,416 KB
最終ジャッジ日時 2024-09-15 07:51:21
合計ジャッジ時間 24,664 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
38,540 KB
testcase_01 AC 74 ms
38,296 KB
testcase_02 AC 74 ms
38,088 KB
testcase_03 AC 74 ms
38,412 KB
testcase_04 AC 73 ms
38,296 KB
testcase_05 AC 72 ms
38,088 KB
testcase_06 AC 71 ms
38,496 KB
testcase_07 AC 73 ms
38,468 KB
testcase_08 AC 74 ms
38,352 KB
testcase_09 AC 76 ms
38,468 KB
testcase_10 AC 75 ms
38,300 KB
testcase_11 AC 74 ms
38,484 KB
testcase_12 AC 72 ms
38,416 KB
testcase_13 AC 72 ms
38,200 KB
testcase_14 AC 73 ms
38,444 KB
testcase_15 AC 72 ms
38,312 KB
testcase_16 AC 73 ms
38,556 KB
testcase_17 AC 71 ms
38,412 KB
testcase_18 AC 74 ms
38,356 KB
testcase_19 AC 71 ms
38,628 KB
testcase_20 AC 74 ms
38,312 KB
testcase_21 AC 72 ms
38,556 KB
testcase_22 AC 75 ms
38,296 KB
testcase_23 AC 73 ms
38,484 KB
testcase_24 AC 72 ms
38,416 KB
testcase_25 AC 80 ms
38,400 KB
testcase_26 AC 74 ms
38,416 KB
testcase_27 AC 74 ms
38,092 KB
testcase_28 AC 71 ms
38,300 KB
testcase_29 AC 74 ms
38,296 KB
testcase_30 AC 74 ms
38,556 KB
testcase_31 AC 71 ms
38,312 KB
testcase_32 AC 77 ms
38,544 KB
testcase_33 AC 245 ms
47,372 KB
testcase_34 AC 271 ms
47,636 KB
testcase_35 AC 134 ms
40,936 KB
testcase_36 AC 256 ms
46,152 KB
testcase_37 AC 242 ms
47,436 KB
testcase_38 AC 263 ms
47,224 KB
testcase_39 AC 279 ms
47,936 KB
testcase_40 AC 272 ms
47,848 KB
testcase_41 AC 274 ms
47,664 KB
testcase_42 AC 273 ms
48,072 KB
testcase_43 AC 169 ms
42,924 KB
testcase_44 AC 259 ms
46,164 KB
testcase_45 AC 262 ms
47,512 KB
testcase_46 AC 242 ms
46,052 KB
testcase_47 AC 257 ms
45,872 KB
testcase_48 AC 135 ms
40,800 KB
testcase_49 AC 284 ms
47,844 KB
testcase_50 AC 156 ms
42,500 KB
testcase_51 AC 136 ms
41,216 KB
testcase_52 AC 136 ms
40,840 KB
testcase_53 AC 276 ms
48,052 KB
testcase_54 AC 224 ms
46,060 KB
testcase_55 AC 272 ms
48,008 KB
testcase_56 AC 202 ms
44,316 KB
testcase_57 AC 281 ms
48,132 KB
testcase_58 AC 169 ms
42,704 KB
testcase_59 AC 273 ms
47,760 KB
testcase_60 AC 204 ms
44,292 KB
testcase_61 AC 281 ms
47,892 KB
testcase_62 AC 274 ms
48,068 KB
testcase_63 AC 180 ms
43,096 KB
testcase_64 AC 278 ms
47,756 KB
testcase_65 AC 224 ms
45,880 KB
testcase_66 AC 140 ms
40,884 KB
testcase_67 AC 206 ms
44,132 KB
testcase_68 AC 155 ms
42,348 KB
testcase_69 AC 269 ms
47,404 KB
testcase_70 AC 248 ms
46,132 KB
testcase_71 AC 190 ms
43,896 KB
testcase_72 AC 154 ms
41,928 KB
testcase_73 AC 215 ms
45,108 KB
testcase_74 AC 185 ms
43,156 KB
testcase_75 AC 250 ms
46,116 KB
testcase_76 AC 190 ms
44,236 KB
testcase_77 AC 265 ms
47,688 KB
testcase_78 AC 253 ms
46,104 KB
testcase_79 AC 174 ms
42,848 KB
testcase_80 AC 164 ms
42,888 KB
testcase_81 AC 153 ms
42,416 KB
testcase_82 AC 248 ms
46,088 KB
testcase_83 AC 280 ms
48,124 KB
testcase_84 AC 280 ms
48,344 KB
testcase_85 AC 284 ms
48,060 KB
testcase_86 AC 284 ms
48,108 KB
testcase_87 AC 275 ms
48,416 KB
testcase_88 AC 283 ms
48,300 KB
testcase_89 AC 275 ms
48,340 KB
testcase_90 AC 272 ms
48,256 KB
testcase_91 AC 275 ms
48,108 KB
testcase_92 AC 280 ms
48,156 KB
testcase_93 AC 74 ms
38,468 KB
testcase_94 AC 75 ms
38,360 KB
testcase_95 AC 254 ms
47,748 KB
testcase_96 AC 272 ms
48,096 KB
testcase_97 AC 261 ms
47,744 KB
testcase_98 AC 246 ms
47,936 KB
testcase_99 AC 276 ms
48,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

public class Main {


  private static void solve() {
    int n = ni();
    long[] a = nal(n);
    
    int g = dfs(a, 0, n);
    if (g == 0) {
      System.out.println("Second");
    } else {
      System.out.println("First");
    }
  }
  
  private static int dfs(long[] a, int l, int r) {
   
    int n = r - l;
    long sum = 0;
    for (int i = l; i < r; i ++) {
      sum += a[i];
    }
    int c = l;
    while (c < r && a[c] * n < sum) {
      c ++;
    }
    
    if (c == l || c == r) {
      return 1;
    } else {
      int g1 = dfs(a, l, c);
      int g2 = dfs(a, c, r);
      if (g1 * g2 == 0) {
        if (g1 + g2 == 1) {
          //0 1
          return 2;
        } else if (g1 + g2 == 2) {
          //0 2
          return 1;
        } else {
          //0 0 
          return 1;
        }
      } else {
        return 0;
      }
    }
    
    
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}
0