結果
問題 | No.78 クジ付きアイスバー |
ユーザー |
|
提出日時 | 2019-10-12 06:20:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 452 bytes |
コンパイル時間 | 586 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 04:38:15 |
合計ジャッジ時間 | 1,974 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
コンパイルメッセージ
main.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 11 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; int N; long K; string s; int sum[55]; long f(long X) { return sum[N]*(X/N)+sum[X%N]; } main() { cin>>N>>K>>s; for(int i=0;i<N;i++)sum[i+1]=sum[i]+(s[i]=='0'?0:s[i]=='1'?1:2); long L=0,R=K; while(R-L>1) { long M=L+R>>1; long T=M,pre=0; int t=114514; while(T<K&&t--) { long now=f(T); if(now==pre)break; T+=now-pre; pre=now; } if(T<K&&pre==f(T))L=M; else R=M; } cout<<R<<endl; }