結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-23 10:36:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,161 bytes |
| コンパイル時間 | 1,512 ms |
| コンパイル使用メモリ | 157,544 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 18:14:01 |
| 合計ジャッジ時間 | 2,807 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 31 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
int N, K;
int main(){
cin >> N >> K;
vector<char> ice_box(N);
REP(i,0,N){
cin >> ice_box[i];
}
int atari = 0;
// 一箱目を食べきるのに必要な買う本数
int first_buy = 0;
int first_atari = 0;
REP(i,0,N){
if (atari > 0) {
--atari;
} else {
++first_buy;
}
atari += ice_box[i] - '0';
}
first_atari = atari;
// 二箱目以降を食べきるのに必要な買う本数
atari = first_atari;
int second_buy = 0;
REP(i,0,N){
if (atari > 0) {
--atari;
} else {
++second_buy;
}
atari += ice_box[i] - '0';
}
// 最後となる箱で買う本数
atari = K < N ? 0 : first_atari;
int last_buy = 0;
REP(i,0,K % N){
if (atari > 0) {
--atari;
} else {
++last_buy;
}
atari += ice_box[i] - '0';
}
if (K < N) {
cout << "last" << endl;
cout << last_buy << endl;
} else {
cout << first_buy + ((K / N) - 1) * second_buy + last_buy << endl;
}
}