結果
| 問題 |
No.3266 岩井星人は見ずにはいられない
|
| コンテスト | |
| ユーザー |
ゼリトキ
|
| 提出日時 | 2025-09-06 15:37:55 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,494 bytes |
| コンパイル時間 | 3,391 ms |
| コンパイル使用メモリ | 276,348 KB |
| 実行使用メモリ | 15,936 KB |
| 最終ジャッジ日時 | 2025-09-06 15:38:06 |
| 合計ジャッジ時間 | 7,152 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 19 WA * 10 TLE * 1 -- * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
const long long mod=998244353;
const long long hmod=46216567629137;
int main(){
cin.tie(0)->sync_with_stdio(0);
cout.tie(0);
ll N,A;
string S;
cin>>N>>A>>S;
int zero=0,one=0;
rep(i,N){
if(S[i]=='0') zero++;
else one++;
}
int maximum=0;
int now=0;
rep(i,N){
if(S[i]=='0') now--;
else now++;
maximum=max(maximum,now);
}
ll ans=0;
if(one-maximum-zero>=0){
ll cnt=(A-1)/(one-maximum);
ans+=N*cnt;
cnt*=(one-maximum);
rep(i,N){
if(cnt==A) break;
if(S[i]=='1'){
cnt++;
}
ans++;
}
cout<<ans<<endl;
return 0;
}
else{
ll now_rate=1200;
ll ans=0;
ll cnt=0;
while(now_rate>=1200-maximum){
ans+=N;
cnt+=one-max(0LL,(maximum-1200+now_rate));
if(cnt>A){
cnt-=one-max(0LL,(maximum-1200+now_rate));
ans-=N;
break;
}
now_rate+=one-max(0LL,(maximum-1200+now_rate))-zero;
}
ll loop=(A-cnt-1)/one;
ans+=N*loop;
cnt+=loop*one;
rep(i,N){
if(cnt==A) break;
if(S[i]=='1'){
cnt++;
}
ans++;
}
cout<<ans<<endl;
}
}
ゼリトキ