QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#647124#362. SparklersKiharaTouma0 0ms3956kbC++141.5kb2024-10-17 11:51:352024-10-17 11:51:36

Judging History

你现在查看的是最新测评结果

  • [2024-10-17 11:51:36]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3956kb
  • [2024-10-17 11:51:35]
  • 提交

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;
}

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: 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%