QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96497 | #2929. Concert Rehearsal | Abdelrahman_K | WA | 2ms | 8220kb | C++14 | 1.9kb | 2023-04-13 22:55:47 | 2023-04-13 22:55:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef long double ld;
#define F first
#define S second
const int N = 1e5 + 2, mod = 1e9 + 7;
const ld eps = 1e-6;
int grid[57][57];
typedef complex<ld> point;
#define X real()
#define Y imag()
int main() {
ll n, p, k;
cin>>n>>p>>k;
ll arr[2 * n + 5], sum = 0;
ll pref[2 * n + 5];
for(int i = 0; i < n; i++){
cin>>arr[i];
sum += arr[i];
arr[i + n] = arr[i];
pref[i] = sum;;
}
ll cur = 0;
for(int i = 0; i < n; i++){
cur += arr[i];
pref[i + n] = sum + cur;
}
ll people[n + 5], next[n + 5];
for(int i = 0; i < n; i++){
people[i] = (p / sum) * n;
ll x = p % sum;
ll start = i, end = i + n - 1, ans = 0;
while(start <= end){
ll mid = (start + end) / 2, a;
a = pref[mid] - (i ? pref[i - 1] : 0);
if(a <= x){
start = mid + 1;
ans = mid - i + 1;
}
else
end = mid - 1;
}
people[i] += ans;
next[i] = (ans + i) % n;
}
// for(int i = 0; i < n; i++){
// cout<<people[i]<<' '<<next[i]<<endl;
// }
ll acc[4 * N + 5];
int last_day[4 * N + 5];
memset(last_day, -1, sizeof last_day);
last_day[0] = 1;
int now = 0;
acc[0] = 0;
acc[1] = people[0];
for(int day = 2; day <= (ll)4e5; day++){
now = next[now];
acc[day] = acc[day - 1] + people[now];
if(last_day[now] != -1){
ll y = acc[day] - (acc[last_day[now]]);
// ll y = (last_day[now] == 0)? acc[day] - acc[last_day[now]] : acc[day];
ll fans = acc[last_day[now]] + y * ((k - last_day[now]) / (day - last_day[now]));
return cout<<fans / n, 0;
}
last_day[now] = day;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8052kb
input:
3 20 10 6 9 5
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 0ms
memory: 8064kb
input:
5 11 2 5 5 5 5 5
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 8220kb
input:
7 11 3 1 2 3 4 5 6 7
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'