結果

問題 No.78 クジ付きアイスバー
ユーザー latte0119latte0119
提出日時 2016-01-22 20:04:18
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 864 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 158,724 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 06:04:40
合計ジャッジ時間 5,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

int N,K;
int S[100000];

int main(){
    cin>>N>>K;
    string str;cin>>str;
    rep(i,N)S[i]=str[i]-'0';
    rep(i,10*N)S[i+N]=S[i];

    int len=0,val=0,get=0;
    rep(i,K){
        if(i%N==0&&i&&get==0){
            len=i;
            break;
        }
        if(get){
            get--;
        }
        else{
            val++;
        }
        get+=S[i];
        if(get>1145){
            cout<<val<<endl;
            return 0;
        }
    }

    int ans=(K/len)*val;
    K%=len;
    get=0;
    rep(i,K){
        if(get){
            get--;
        }
        else{
            ans++;
        }
        get+=S[i];
    }

    cout<<ans<<endl;
    return 0;
}
0