結果
| 問題 | No.1097 Remainder Operation |
| コンテスト | |
| ユーザー |
tricky_epithet
|
| 提出日時 | 2026-10-06 23:14:49 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 166 ms / 2,000 ms |
| + 406µs | |
| コード長 | 1,525 bytes |
| 記録 | |
| コンパイル時間 | 3,242 ms |
| コンパイル使用メモリ | 360,220 KB |
| 実行使用メモリ | 11,904 KB |
| 最終ジャッジ日時 | 2026-10-06 23:15:09 |
| 合計ジャッジ時間 | 8,315 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
/*
n = 7
a0 = 9
*/
int main() {
// ll t; cin >> t;
// while (t--) {
ll n; cin >> n;
vector<ll> v(n);
for (int i = 0; i < n; ++i) cin >> v[i];
ll q; cin >> q;
ll thresh = 0;
vector<ll> precomp(n + 3, 0);
map<ll, ll> freq;
ll x = 0;
ll sum = 0;
ll thresh2 = 0;
ll bforeloop = 0;
vector<ll> precomp2(n + 3, 0);
while (true) {
ll idx = x % n;
freq[idx]++;
if (freq[idx] > 1) {
if (freq[idx] > 2) break;
x += v[idx];
sum += v[idx];
thresh2++;
precomp2[thresh2] = sum;
continue;
}
++thresh;
bforeloop = thresh;
x += v[idx];
// sum += v[idx];
precomp[thresh] = x;
}
while (q--) {
ll k; cin >> k;
ll ans = 0;
if (k >= bforeloop) {
ans += precomp[bforeloop];
k -= bforeloop;
ll mult = k / thresh2;
ans += sum * mult;
ll off = k % thresh2;
ans += precomp2[off];
cout << ans << endl;
}
else {
cout << precomp[k] << endl;
}
}
// }
}
tricky_epithet