結果

問題 No.761 平均値ゲーム
ユーザー hiromi_ayasehiromi_ayase
提出日時 2018-12-09 02:29:10
言語 Java19
(openjdk 21)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 3,211 bytes
コンパイル時間 2,562 ms
コンパイル使用メモリ 88,136 KB
実行使用メモリ 59,408 KB
最終ジャッジ日時 2023-10-13 10:49:01
合計ジャッジ時間 25,682 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
50,968 KB
testcase_01 AC 70 ms
50,812 KB
testcase_02 AC 69 ms
50,836 KB
testcase_03 AC 69 ms
50,876 KB
testcase_04 AC 68 ms
50,852 KB
testcase_05 AC 68 ms
49,016 KB
testcase_06 AC 70 ms
51,032 KB
testcase_07 AC 68 ms
50,896 KB
testcase_08 AC 69 ms
50,968 KB
testcase_09 AC 69 ms
50,736 KB
testcase_10 AC 68 ms
50,748 KB
testcase_11 AC 70 ms
51,132 KB
testcase_12 AC 68 ms
50,812 KB
testcase_13 AC 69 ms
50,616 KB
testcase_14 AC 69 ms
50,916 KB
testcase_15 AC 70 ms
50,932 KB
testcase_16 AC 69 ms
50,740 KB
testcase_17 AC 70 ms
50,844 KB
testcase_18 AC 69 ms
50,820 KB
testcase_19 AC 68 ms
50,608 KB
testcase_20 AC 69 ms
50,760 KB
testcase_21 AC 70 ms
48,956 KB
testcase_22 AC 69 ms
51,020 KB
testcase_23 AC 69 ms
51,236 KB
testcase_24 AC 70 ms
50,816 KB
testcase_25 AC 70 ms
50,860 KB
testcase_26 AC 69 ms
50,816 KB
testcase_27 AC 68 ms
51,076 KB
testcase_28 AC 69 ms
50,972 KB
testcase_29 AC 68 ms
50,768 KB
testcase_30 AC 67 ms
51,032 KB
testcase_31 AC 70 ms
50,844 KB
testcase_32 AC 68 ms
50,684 KB
testcase_33 AC 255 ms
58,660 KB
testcase_34 AC 252 ms
58,660 KB
testcase_35 AC 139 ms
53,976 KB
testcase_36 AC 234 ms
56,908 KB
testcase_37 AC 253 ms
58,532 KB
testcase_38 AC 247 ms
58,636 KB
testcase_39 AC 264 ms
58,916 KB
testcase_40 AC 260 ms
58,860 KB
testcase_41 AC 266 ms
58,924 KB
testcase_42 AC 261 ms
58,492 KB
testcase_43 AC 173 ms
56,268 KB
testcase_44 AC 245 ms
58,948 KB
testcase_45 AC 261 ms
58,784 KB
testcase_46 AC 223 ms
57,012 KB
testcase_47 AC 238 ms
56,812 KB
testcase_48 AC 115 ms
53,964 KB
testcase_49 AC 265 ms
59,408 KB
testcase_50 AC 159 ms
54,912 KB
testcase_51 AC 141 ms
53,812 KB
testcase_52 AC 142 ms
54,096 KB
testcase_53 AC 257 ms
58,920 KB
testcase_54 AC 240 ms
57,244 KB
testcase_55 AC 262 ms
58,832 KB
testcase_56 AC 201 ms
57,244 KB
testcase_57 AC 273 ms
59,268 KB
testcase_58 AC 170 ms
56,856 KB
testcase_59 AC 257 ms
58,848 KB
testcase_60 AC 200 ms
57,284 KB
testcase_61 AC 265 ms
59,192 KB
testcase_62 AC 265 ms
58,904 KB
testcase_63 AC 180 ms
54,628 KB
testcase_64 AC 256 ms
58,636 KB
testcase_65 AC 223 ms
57,184 KB
testcase_66 AC 139 ms
54,380 KB
testcase_67 AC 201 ms
56,772 KB
testcase_68 AC 159 ms
54,580 KB
testcase_69 AC 261 ms
58,648 KB
testcase_70 AC 234 ms
54,768 KB
testcase_71 AC 187 ms
57,020 KB
testcase_72 AC 152 ms
54,652 KB
testcase_73 AC 201 ms
57,044 KB
testcase_74 AC 185 ms
56,884 KB
testcase_75 AC 229 ms
56,916 KB
testcase_76 AC 193 ms
57,008 KB
testcase_77 AC 253 ms
59,020 KB
testcase_78 AC 237 ms
57,096 KB
testcase_79 AC 177 ms
57,128 KB
testcase_80 AC 164 ms
56,920 KB
testcase_81 AC 158 ms
54,324 KB
testcase_82 AC 244 ms
56,956 KB
testcase_83 AC 281 ms
58,916 KB
testcase_84 AC 268 ms
59,372 KB
testcase_85 AC 259 ms
58,816 KB
testcase_86 AC 268 ms
58,784 KB
testcase_87 AC 269 ms
59,036 KB
testcase_88 AC 263 ms
59,012 KB
testcase_89 AC 273 ms
58,756 KB
testcase_90 AC 264 ms
58,828 KB
testcase_91 AC 269 ms
58,852 KB
testcase_92 AC 271 ms
58,896 KB
testcase_93 AC 69 ms
50,980 KB
testcase_94 AC 70 ms
49,392 KB
testcase_95 AC 242 ms
58,764 KB
testcase_96 AC 258 ms
58,988 KB
testcase_97 AC 250 ms
58,836 KB
testcase_98 AC 254 ms
58,668 KB
testcase_99 AC 252 ms
59,068 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