結果
| 問題 |
No.3266 岩井星人は見ずにはいられない
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-11 21:02:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 994 bytes |
| コンパイル時間 | 6,539 ms |
| コンパイル使用メモリ | 258,968 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-09-11 21:03:06 |
| 合計ジャッジ時間 | 8,097 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); ++i)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define fore(i, a) for(auto &i:a)
using ll = long long;
#define DEBUG(x) cerr << #x << ": "; for (auto _ : x) cerr << _ << " "; cerr << endl;
int main() {
ll n,a; cin >> n >> a;
string s;cin >> s;
ll now = 1200;
ll ac1 = 0;
ll ac2 = 0;
vector<ll> ivent1, ivent2;
rep(i, n){
if(s[i] == '1' && now < 1200){
ac1++;
ivent1.push_back(i);
now++;
}
else if(s[i] == '0'){
now--;
}
}
rep(i, n){
if(s[i] == '1' && now < 1200){
ac2++;
ivent2.push_back(i);
now++;
}
else if(s[i] == '0'){
now--;
}
}
ll ans;
if(a <= ac1){
ans = ivent1[a-1]+1;
}
else{
a -= ac1;
auto[q, r] = div(a, ac2);
if(r == 0){
ans = q*n+ivent2[ac2-1]+1;
}
else{
ans = (q+1)*n+ivent2[r-1]+1;
}
}
cout << ans << endl;
}