結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-26 16:57:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,101 bytes |
| コンパイル時間 | 730 ms |
| コンパイル使用メモリ | 82,040 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-09 17:51:51 |
| 合計ジャッジ時間 | 2,203 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 6 WA * 29 |
ソースコード
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;
int main()
{
int n;
ll k;
string s;
cin >> n >> k >> s;
s += s;
ll num = 1;
for (int i = 0; i < n*2-1; i++) {
if (s[i] == '2' && s[i + 1] == '0') {
s[i + 1] = '1';
}
}
for (int i = 1; i < n; i++) {
if (s[i - 1] == '0')num++;
}
ll ans = 0;
if (n < k) {
int buy[110],buy_num=0;
int nes = (k - n)/n;
for (int i = n; i < n * 2; i++) {
if (s[i - 1] == '0') {
buy[i] = 1;
buy_num++;
}
}
ans += nes * buy_num;
for (int i = n; i < (n + (k - n) % n)-1; i++) {
if (buy[i])ans++;
}
}
else {
num = 1;
for (int i = 1; i < n; i++) {
if (s[i - 1] == '0') {
num++;
}
}
}
cout << ans + num << endl;
return 0;
}