結果

問題 No.78 クジ付きアイスバー
ユーザー koba-e964koba-e964
提出日時 2016-11-30 23:00:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,283 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 88,376 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-18 10:08:20
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  ll k;
  cin >> n >> k;
  string s;
  cin >> s;
  int tot = 0;
  REP(i, 0, n) {
    tot += s[i] - '0';
  }
  if (tot >= n) {
    int acc = 0;
    int last = 0;
    REP(i, 0, n) {
      if (i + 1 > acc) {
	last = max(last, i + 1 - acc);
      }
      acc += s[i] - '0';
    }
    cout << last << endl;
    return 0;
  }
  int r = k % n;
  ll acc = k - k / n * tot;
  VI te(2 * n);
  int cur = 0;
  int cnt = 0;
  REP(i, 0, 2 * n) {
    if (cur >= 1) {
      cur--;
      cnt++;
    }
    cur += s[i % n] - '0';
    te[i] = cur;
  }
  //acc -= cnt;
  cout << (k >= n ? acc - te[n + r - 2] + tot : k - (k >= 2 ? te[k - 2] : 0)) << endl;
}
0