結果
問題 |
No.3266 岩井星人は見ずにはいられない
|
ユーザー |
|
提出日時 | 2025-09-06 14:47:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,151 bytes |
コンパイル時間 | 2,041 ms |
コンパイル使用メモリ | 198,092 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-06 14:48:01 |
合計ジャッジ時間 | 3,052 ms |
ジャッジサーバーID (参考情報) |
judge / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, a; string s; cin >> n >> a >> s; vector<ll> ac(21), rt(21); ll rtg = 0, cor = 0; for(int j = 0; j < 20; j++){ for(int i = 0; i < n; i++){ if(s[i] == '1'){ if(rtg < 0) cor++, rtg++; if(cor == a){ cout << j * n + i + 1 << '\n'; return 0; } }else{ rtg--; } } ac[j + 1] = cor; rt[j + 1] = rtg; } assert(ac[20] - ac[19] == ac[19] - ac[18]); assert(rt[20] - rt[19] == rt[19] - rt[18]); ll d = (a - ac[20] - 1) / (ac[20] - ac[19]); rtg += d * (rt[20] - rt[19]); cor += d * (ac[20] - ac[19]); d += 20; for(int i = 0; i < s.size(); i++){ if(s[i] == '1'){ if(rtg < 0) cor++, rtg++; if(cor == a){ cout << d * n + i + 1 << '\n'; return 0; } }else{ rtg--; } } cerr << "enter" << '\n'; }