結果
問題 |
No.2217 Suffix+
|
ユーザー |
![]() |
提出日時 | 2023-08-29 11:45:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 803 bytes |
コンパイル時間 | 1,700 ms |
コンパイル使用メモリ | 166,712 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-30 23:20:22 |
合計ジャッジ時間 | 3,966 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 7 WA * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; unsigned long long n, k, a[MAXN], mins = 1e18, b[MAXN]; bool F(unsigned long long x){ for(int i = 1; i <= n; i++){ if(a[i] < x){ b[i] = x - a[i]; } else { b[i] = 0; } } unsigned long long xx = 0, s = 0; for(int i = 1; i <= n; i++){ if(b[i]){ if(b[i] > s){ xx += (b[i] + i - 1) / i; s += (b[i] + i - 1) / i * i; } } } return xx <= k; } int main(){ cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> a[i]; mins = min(mins, a[i]); } unsigned long long l = 0, r = mins + k * n; while(l < r){ unsigned long long mid = (l + r + 1) >> 1; if(F(mid)){ l = mid; } else { r = mid - 1; } } cout << l; return 0; }