QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647144 | #362. Sparklers | KiharaTouma | 0 | 0ms | 3900kb | C++14 | 1.3kb | 2024-10-17 12:02:03 | 2024-10-17 12:02:03 |
answer
//qoj362
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int n, k, T, a[N];
bool chk(int val){
int l = k, r = k, lin = 0, rin = 0, sum = T * val * 2;
while(l != 1 && r != n){
int x = a[l] - a[l-1] - lin;
int y = a[r+1] - a[r] - rin;
if(min(x, y) > sum) return 0;
if(x < y){
lin += a[l] - a[l-1];
sum = sum + T * val * 2 - x;
-- l;
} else {
rin += a[r+1] - a[r];
sum = sum + T * val * 2 - y;
++ r;
}
}
while(l != 1){
int x = a[l] - a[l-1] - lin;
if(x > sum) return 0;
lin += a[l] - a[l-1];
sum = sum + T * val * 2 - x;
-- l;
}
while(r != n){
int y = a[r+1] - a[r] - rin;
if(y > sum) return 0;
rin += a[r+1] - a[r];
sum = sum + T * val * 2 - y;
++ r;
}
return 1;
}
signed main(){
scanf("%lld%lld%lld", &n, &k, &T);
for(int i = 1; i <= n; ++ i){
scanf("%lld", &a[i]);
}
int l = 0, r = 1e9;
while(l < r){
int mid = l + r >> 1;
if(chk(mid)){
r = mid;
} else {
l = mid + 1;
}
}
printf("%lld\n", l);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3900kb
input:
10 9 2 0 1117660 2284171 3390084 3568342 4222750 5180454 6186411 6360445 6519656
output:
97098
result:
wrong answer 1st lines differ - expected: '181102', found: '97098'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%