結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-16 14:15:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 511 bytes |
| コンパイル時間 | 4,751 ms |
| コンパイル使用メモリ | 71,268 KB |
| 最終ジャッジ日時 | 2025-01-24 14:15:42 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
int main(void){
int n;
ll k;
cin >> n >> k;
string s;
cin >> s;
vector<ll> acc(n + 1);
ll now = 0;
REP(i, 0, n) {
int d = s[i] - '0';
acc[i + 1] = now + 1;
now += 1 - d;
}
ll ans = 0;
REP(i, 1, min((ll) n, k) + 1) {
ll q = (k - i) / n;
ans = max(ans, acc[i] + q * max(0LL, now));
}
cout << ans << endl;
}