結果
問題 |
No.2217 Suffix+
|
ユーザー |
|
提出日時 | 2023-03-06 13:03:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 86,364 KB |
最終ジャッジ日時 | 2025-02-11 05:43:21 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d %d", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:27:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | for (i=0; i<n; i++) scanf("%lld", &as[i]); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include <map> #include <vector> #include <queue> #include <deque> #include <set> #include <stack> #include <algorithm> #include <array> #include <unordered_set> #include <unordered_map> #include <string> using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; LL as[100004]; int main() { int n, i, k; LL b, d, x, nb, s, c, j; scanf("%d %d", &n, &k); for (i=0; i<n; i++) scanf("%lld", &as[i]); b=0; d=2; for (i=0; i<14; i++) d*=10; x=d; while(d) { while(1) { nb=b+d; if (nb>x) break; s=0; c=0; for (i=0; i<n; i++) { if (as[i]+s>=nb) continue; j=(nb-as[i]-s+i)/(i+1); c+=j; s+=j*(i+1); if (c>k) break; } if (c>k) break; b=nb; } d>>=1; } printf("%lld\n", b); return 0; }