結果

問題 No.78 クジ付きアイスバー
ユーザー なおなお
提出日時 2014-11-26 00:17:39
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 920 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 158,180 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-16 04:51:03
合計ジャッジ時間 53,379 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1,013 ms
5,376 KB
testcase_06 AC 2,626 ms
5,376 KB
testcase_07 AC 1,040 ms
5,376 KB
testcase_08 AC 1,599 ms
5,376 KB
testcase_09 TLE -
testcase_10 AC 2,755 ms
5,376 KB
testcase_11 AC 1,381 ms
5,376 KB
testcase_12 AC 4,594 ms
5,376 KB
testcase_13 AC 4,901 ms
5,376 KB
testcase_14 AC 4,928 ms
5,376 KB
testcase_15 AC 1,928 ms
5,376 KB
testcase_16 AC 3,483 ms
5,376 KB
testcase_17 AC 4,077 ms
5,376 KB
testcase_18 AC 4,125 ms
5,376 KB
testcase_19 RE -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 RE -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 2 ms
5,376 KB
testcase_38 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define REPEAT(i, k, n)     for(int(i)=(k);(i)<((k)+(n));++(i))


int dp[10000];

int main(){
    int N,K;
    cin >> N >> K;

    string s;
    cin >> s;
    dp[0] = 0;

    int get = 0, buy = 0;
    while(1){
        int cnt = 1, add = 1; buy++;
        while(add){
            int n = s[get%N]-'0';
            get++;
            add--; add += n;
            cnt += n;
            if(get > K) break;
        }
        dp[buy] = get;
        if(get > K) break;
        if(get % N == 0) break;
    }
    int res = 0;
    if(K >= get){
        res += (K / get) * buy;
        K %= get;
    }
    for(int i = 0; i <= buy; i++){
        if(dp[i] >= K){
            res += i;
            break;
        }
    }
    cout << res << endl;

    return 0;
}
0