QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#647124 | #362. Sparklers | KiharaTouma | 0 | 0ms | 3956kb | C++14 | 1.5kb | 2024-10-17 11:51:35 | 2024-10-17 11:51:36 |
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, us = 0;
while(l != 1 && r != n){
int x = a[l] - a[l-1] - lin;
int y = a[r+1] - a[r] - rin;
if(us + min(x, y) > sum * val * 2){
// printf("%d %d\n", l, r);
return 0;
}
if(x <= y){
lin += a[l] - a[l-1];
sum += T;
us += a[l] - a[l-1];
-- l;
} else {
rin += a[r+1] - a[r];
sum += T;
us += a[r+1] - a[r];
++ r;
}
}
while(l != 1){
int x = a[l] - a[l-1] - lin;
if(us + x > sum * val * 2){
return 0;
}
lin += a[l] - a[l-1];
sum += T;
us += a[l] - a[l-1];
-- l;
}
while(r != n){
int y = a[r+1] - a[r] - rin;
if(us + y > sum * val * 2){
return 0;
}
rin += a[r+1] - a[r];
sum += T;
us += a[r+1] - a[r];
++ r;
}
return 1;
}
signed main(){
scanf("%d%d%d", &n, &k, &T);
for(int i = 1; i <= n; ++ i){
scanf("%d", &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("%d\n", l);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3956kb
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%