結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
|
提出日時 | 2025-06-30 01:39:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 2,085 ms |
コンパイル使用メモリ | 196,272 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-30 01:39:10 |
合計ジャッジ時間 | 3,713 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; string s; cin >> s; vector<int> buy(N+1); int bring = 0,answer = 0,sum = 0; for(int i=0; i<min(N,K); i++){ if(bring == 0) bring++,answer++; bring--,bring += s.at(i)-'0',sum += s.at(i)-'0'; buy.at(answer) = i+1; } for(int i=answer+1; i<=N; i++) buy.at(i) = N; K -= N; if(K <= 0 || sum >= N){cout << answer << endl; return 0;} answer += (N-sum)*((K-1)/N),K %= N; if(K == 0) K = N; for(int i=0; ; i++) if(buy.at(i+bring) >= K){cout << answer+i << endl; break;} }