結果

問題 No.1211 円環はお断り
ユーザー m_tsubasam_tsubasa
提出日時 2020-08-30 15:12:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,106 bytes
コンパイル時間 2,223 ms
コンパイル使用メモリ 211,412 KB
実行使用メモリ 38,288 KB
最終ジャッジ日時 2024-04-27 08:05:20
合計ジャッジ時間 32,990 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1,389 ms
17,920 KB
testcase_14 AC 1,713 ms
22,816 KB
testcase_15 AC 1,801 ms
22,272 KB
testcase_16 TLE -
testcase_17 AC 203 ms
6,940 KB
testcase_18 AC 1,642 ms
20,096 KB
testcase_19 AC 221 ms
6,940 KB
testcase_20 AC 276 ms
6,940 KB
testcase_21 AC 270 ms
6,940 KB
testcase_22 AC 1,497 ms
18,432 KB
testcase_23 AC 1,661 ms
21,120 KB
testcase_24 AC 937 ms
13,440 KB
testcase_25 AC 47 ms
6,944 KB
testcase_26 AC 1,952 ms
23,808 KB
testcase_27 AC 961 ms
13,572 KB
testcase_28 TLE -
testcase_29 AC 1,586 ms
20,096 KB
testcase_30 TLE -
testcase_31 AC 853 ms
12,416 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, k;
vector<long long> a;

long long solve();
bool ch(long long x);

int main() {
  cin >> n >> k;
  a.resize(2 * n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i + n] = a[i];
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long l = 0, r = 1;
  for (int i = 0; i < n; ++i) r += a[i];
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    if (ch(mid))
      l = mid;
    else
      r = mid;
  }
  return l;
}
bool ch(long long x) {
  vector<long long> memo(n, -1);
  for (long long i = 0, sum = 0, r = 0; i < n; ++i) {
    while (r < 2 * n && sum < x) sum += a[r++];
    memo[i] = r - i;
    sum -= a[i];
  }
  vector<vector<long long>> dp;
  dp.resize(32, vector<long long>(n));
  dp[0] = memo;
  for (int i = 1; i <= 30; ++i)
    for (int j = 0; j < n; ++j)
      dp[i][j] = dp[i - 1][j] + dp[i - 1][(j + dp[i - 1][j]) % n];
  for (int i = 0; i < n; ++i) {
    long long cnt = 0;
    for (int j = 0; j <= 30; ++j)
      if (k >> j & 1) cnt += dp[j][(i + cnt) % n];
    if (cnt <= n) return 1;
  }
  return 0;
}
0