結果
問題 | No.2217 Suffix+ |
ユーザー |
![]() |
提出日時 | 2023-04-23 16:46:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 2,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 41,696 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 23:40:28 |
合計ジャッジ時間 | 3,482 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
/* -*- coding: utf-8 -*- * * 2217.cc: No.2217 Suffix+ - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ typedef long long ll; /* global variables */ ll as[MAX_N]; /* subroutines */ ll check(int n, ll x) { ll c = 0, s = 0; for (int i = 0; i < n; i++) if (x > as[i] + s) { ll d = (x - (as[i] + s) + i) / (i + 1); c += d; s += d * (i + 1); } return c; } /* main */ int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%lld", as + i); ll x0 = 0, x1 = 200000000000000LL + 1; while (x0 + 1 < x1) { ll x = (x0 + x1) / 2; if (check(n, x) > k) x1 = x; else x0 = x; } printf("%lld\n", x0); return 0; }