結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2016-02-16 15:29:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 514 bytes |
コンパイル時間 | 434 ms |
コンパイル使用メモリ | 55,224 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-06 19:02:02 |
合計ジャッジ時間 | 1,359 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 WA * 2 |
ソースコード
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int s[n+1]; int free = 0; s[0] = 0; for (int i = 1; i <= n; i++) { char c; cin >> c; s[i] = s[i-1] + 1; if (free > 0) { s[i]--; free--; } free += atoi(&c); } int ans; if (k > n) ans = s[n] + max(0,(s[n] - free) * (k / n - 1)) + max(0,s[k%n]-free); else ans = s[k]; cout << ans << endl; return 0; }