QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54115 | #2929. Concert Rehearsal | Beevo# | WA | 2ms | 3688kb | C++23 | 1.5kb | 2022-10-06 22:31:34 | 2022-10-06 22:31:37 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
#define ll long long
#define ld long double
#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void testCase() {
int n, p, k;
cin >> n >> p >> k;
ll d[n];
for (int i = 0; i < n; i++) {
cin >> d[i];
if (i)
d[i] += d[i - 1];
}
ll curP = p % d[n - 1];
auto sum = [&] (int i, int m) {
ll cur = d[min(i + m, n - 1)] - (i ? d[i - 1] : 0);
if (i + m >= n)
cur += d[i + m - n];
return cur;
};
int nxt[n];
for (int i = 0; i < n; i++) {
int l = 0, r = n - 1, m;
while (l <= r) {
m = (l + r) >> 1;
if (sum(i, m) > curP)
r = m - 1;
else
l = m + 1;
}
nxt[i] = (i + l) % n;
}
int orgK = k;
ll sol = 0;
int cur = 0;
vector<int> freq(n);
while (!freq[cur] && k) {
k--;
freq[cur]++;
sol += (nxt[cur] < cur);
cur = nxt[cur];
}
int st = cur;
ll re = 0, cst = 0;
do {
re += (nxt[cur] < cur);
cur = nxt[cur];
cst++;
} while (st != cur);
sol += 1LL * (p / d[n - 1]) * orgK;
sol += 1LL * (k / cst) * re;
cout << sol;
}
signed main() {
Beevo
int T = 1;
// cin >> T;
while (T--)
testCase();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3616kb
input:
3 20 10 6 9 5
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
5 11 2 5 5 5 5 5
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
7 11 3 1 2 3 4 5 6 7
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
4 8 9 2 7 2 3
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 3 7 2
output:
7
result:
ok single line: '7'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
1 1000000000 1000000000 1
output:
1000000000000000000
result:
ok single line: '1000000000000000000'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
5 999999999 999999999 2 1 4 7 3
output:
58823528941176471
result:
ok single line: '58823528941176471'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
5 5 1000 2 2 2 2 2
output:
400
result:
ok single line: '400'
Test #9:
score: -100
Wrong Answer
time: 2ms
memory: 3688kb
input:
980 991 978 2 1 2 1 2 3 1 1 1 3 3 3 2 2 2 2 3 3 1 3 1 2 2 3 1 2 3 3 2 3 1 2 2 3 1 3 1 3 2 2 2 1 1 2 3 3 1 2 1 1 1 2 2 2 3 3 2 1 3 3 1 3 3 1 1 2 1 1 1 1 2 1 2 3 2 1 1 3 3 2 2 1 3 3 3 2 2 3 1 2 3 3 2 2 3 2 3 2 2 2 1 3 3 1 1 3 1 2 2 2 2 1 2 2 1 1 3 2 1 1 3 1 2 3 3 3 3 3 2 2 2 3 3 1 1 2 1 3 3 3 2 2 2 3 ...
output:
421
result:
wrong answer 1st lines differ - expected: '492', found: '421'