結果
問題 | No.78 クジ付きアイスバー |
ユーザー | 🍮かんプリン |
提出日時 | 2019-08-09 13:43:17 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,684 bytes |
コンパイル時間 | 1,391 ms |
コンパイル使用メモリ | 144,332 KB |
実行使用メモリ | 4,508 KB |
最終ジャッジ日時 | 2023-09-26 12:14:44 |
合計ジャッジ時間 | 3,829 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,384 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,384 KB |
testcase_07 | AC | 1 ms
4,384 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,384 KB |
testcase_11 | AC | 1 ms
4,384 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,384 KB |
testcase_14 | AC | 2 ms
4,384 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 1 ms
4,380 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 1 ms
4,380 KB |
testcase_23 | AC | 1 ms
4,384 KB |
testcase_24 | AC | 1 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,384 KB |
testcase_26 | AC | 1 ms
4,384 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 2 ms
4,384 KB |
testcase_31 | AC | 2 ms
4,380 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 2 ms
4,384 KB |
testcase_35 | WA | - |
testcase_36 | AC | 2 ms
4,384 KB |
testcase_37 | WA | - |
testcase_38 | AC | 1 ms
4,380 KB |
ソースコード
#pragma region include #include "bits/stdc++.h" #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define REPR(i, n) for(int i = (int)(n); i >= 0; i--) #define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++) using namespace std; typedef long long ll; typedef pair<int, int> PII; const int MOD = 1e9 + 7; const int INF = 1e9 + 6; const ll LLINF = 4e18; void input() {} template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); } template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); } template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); } template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); } template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); } #pragma endregion int main() { int n, k; input(n,k); string s; cin >> s; int a=0, b=0; int ans=0; REP(i, n) { if (s[i]=='0') { if (b > 0) { b--; } else { a++; } } else { if (b > 0) { b--; } else { a++; } b += s[i] - '0'; } if (k == i + 1) { ans = a; } } if (ans > 0) { cout << ans << endl; } else { if (b >= a) { cout << a << endl; } else { cout << a + (a - b)*(k / s.size() - 1) << endl; } } getchar(); getchar(); }