Submission #581762

# Submission time Handle Problem Language Result Execution time Memory
581762 2022-06-23T05:55:23 Z 박상훈(#8364) Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const ll INF = 4e18;
int d[100100], n, k, t;

bool solve(int s){
    int l = k, r = k;
    __int128 rem = (ll)t * s * 2;

    while(r-l+1<n){
        ll dL = 4e18, dR = 4e18;
        if (l>1) dL = d[l-1];
        if (r<n) dR = d[r];

        if (dL < dR){
            if (rem < dL) return 0;
            rem += (ll)t * s * 2 - dL;
            //rem = min(rem, INF);
            --l;
        }
        else{
            if (rem < dR) return 0;
            rem += (ll)t * s  * 2 - dR;
            //rem = min(rem, INF);
            ++r;
        }
    }
    return 1;
}

int main(){
    scanf("%d %d %d", &n, &k, &t);
    int prv = 0;
    for (int i=0;i<n;i++){
        int cur;
        scanf("%d", &cur);
        d[i] = cur - prv;
        prv = cur;
    }

    int l = 0, r = 1e9, ans = 1e9;
    while(l<=r){
        int m = (l+r)>>1;
        if (solve(m)) ans = m, r = m-1;
        else l = m+1;
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     scanf("%d %d %d", &n, &k, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%d", &cur);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -