結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
|
提出日時 | 2025-06-18 15:17:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 2,249 ms |
コンパイル使用メモリ | 195,772 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-18 15:18:02 |
合計ジャッジ時間 | 3,940 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; size_t N; ll K; string S; ll tot[100001]; void solve(){ cin>>N>>K; cin>>S; size_t i=0,y=0,x; for(x=1;x<=N*10;++x){ if(y==0) ++i,++y; tot[x]=i; y+=S[(x-1)%N]-'0'-1; } if(K<=(ll)N*10) { cout<<tot[K]<<endl; return; } ll diff=tot[N*8]-tot[N*7]; ll a=(K/N)-7; cout<<tot[7*N+K%N]+a*diff<<endl; } int main(int argc, char** argv) { if(argc==1){ ios::sync_with_stdio(0); cin.tie(0); } string s; size_t i; for(i=0;i<(size_t)argc-1;++i){ s+=argv[i+1]; s+='\n'; } for(i=0;i<s.size();++i) ungetc(s[s.size()-1-i], stdin); solve(); return 0; }