結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
sugim48
|
| 提出日時 | 2014-11-25 23:54:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,288 bytes |
| コンパイル時間 | 870 ms |
| コンパイル使用メモリ | 80,204 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 23:42:29 |
| 合計ジャッジ時間 | 1,904 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
ソースコード
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };
ll MOD = 10000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int main() {
int N, K; cin >> N >> K;
string S; cin >> S;
int atari = 0, prev_atari = 0, buy = 0, prev_buy = 0, eat = 0, prev_eat = 0;
for (;;) {
for (int i = 0; i < N; i++) {
if (eat >= K) {
cout << buy << endl;
return 0;
}
if (atari > 0) atari--;
else buy++;
atari += S[i] - '0';
eat++;
}
if (atari >= N) {
cout << buy << endl;
return 0;
}
if (atari == prev_atari) {
int x = (K - eat) / (eat - prev_eat);
buy += x * (buy - prev_buy);
eat += x * (eat - prev_eat);
}
prev_atari = atari;
prev_buy = buy;
prev_eat = eat;
}
}
sugim48