답안 #581775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
581775 2022-06-23T06:09:19 Z 반딧불(#8365) Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
ll t;
ll arr[100002];

bool able(ll speed){
    speed*=t*2;
    int l = k, r = k;
    ll s = arr[k], e = arr[k];
    ll len = 0;
    for(int cnt=1; cnt<n; cnt++){
        ll lDist = arr[l] - arr[l-1];
        ll rDist = arr[r+1] - arr[r];
        if(min(lDist, rDist)+len > speed*cnt) return false;
        if(lDist < rDist) l--, len+=lDist;
        else r++, len+=rDist;
    }
    return true;
}

int main(){
    scanf("%d %d %lld", &n, &k, &t);
    for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
    arr[0] = -1e18, arr[n+1] = 1e18;
    if(arr[1] == arr[n]){
        puts("0");
        return 0;
    }

    ll L = 1, R = 1e9, ANS = 1e9;
    while(L<=R){
        ll MID = (L+R)/2;
        if(able(MID)) ANS = MID, R = MID-1;
        else L = MID+1;
    }
    printf("%lld", ANS);
}

Compilation message

sparklers.cpp: In function 'bool able(ll)':
sparklers.cpp:14:8: warning: unused variable 's' [-Wunused-variable]
   14 |     ll s = arr[k], e = arr[k];
      |        ^
sparklers.cpp:14:20: warning: unused variable 'e' [-Wunused-variable]
   14 |     ll s = arr[k], e = arr[k];
      |                    ^
sparklers.cpp: In function 'int main()':
sparklers.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d %d %lld", &n, &k, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:28:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 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 -