답안 #204343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204343 2020-02-25T13:02:57 Z mhy908 Sparklers (JOI17_sparklers) C++14
100 / 100
543 ms 2936 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortvec(x) sort(all(x))
#define compress(x) x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=1987654321987654321;
const int inf=2000000000;
int n, k;
LL t, arr[100010], mv[100010];
bool poss(LL s){
    for(int i=1; i<=n; i++)mv[i]=arr[i]-2ll*s*t*i;
    if(mv[1]<mv[n])return false;
    int l1=k, r1=k, l2=1, r2=n;
    while(1){
        int l=l1-1, r=r1+1;
        bool br=true;
        while(l>=1&&mv[l]>=mv[r1]){
            if(mv[l]>=mv[l1]){
                l1=l;
                br=false;
                break;
            }
            l--;
        }
        while(r<=n&&mv[r]<=mv[l1]){
            if(mv[r]<=mv[r1]){
                r1=r;
                br=false;
                break;
            }
            r++;
        }
        if(br)break;
    }
    while(1){
        int l=l2+1, r=r2-1;
        bool br=true;
        while(l<=k&&mv[l]>=mv[r2]){
            if(mv[l]>=mv[l2]){
                l2=l;
                br=false;
                break;
            }
            l++;
        }
        while(r>=k&&mv[r]<=mv[l2]){
            if(mv[r]<=mv[r2]){
                r2=r;
                br=false;
                break;
            }
            r--;
        }
        if(br)break;
    }
    return l1<=l2&&r1>=r2;
}
int main(){
    scanf("%d %d %lld", &n, &k, &t);
    for(int i=1; i<=n; i++)scanf("%lld", &arr[i]);
    LL l=0, r=1000000000ll;
    while(l<r){
        LL mid=(l+r)/2;
        if(poss(mid))r=mid;
        else l=mid+1;
    }
    printf("%lld", l);
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %lld", &n, &k, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:69:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%lld", &arr[i]);
                            ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 380 KB Output is correct
17 Correct 5 ms 372 KB Output is correct
18 Correct 4 ms 376 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 380 KB Output is correct
17 Correct 5 ms 372 KB Output is correct
18 Correct 4 ms 376 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 6 ms 380 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 380 KB Output is correct
17 Correct 5 ms 372 KB Output is correct
18 Correct 4 ms 376 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 6 ms 380 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 5 ms 376 KB Output is correct
41 Correct 543 ms 2040 KB Output is correct
42 Correct 6 ms 376 KB Output is correct
43 Correct 232 ms 896 KB Output is correct
44 Correct 47 ms 2936 KB Output is correct
45 Correct 43 ms 2808 KB Output is correct
46 Correct 34 ms 2812 KB Output is correct
47 Correct 34 ms 2808 KB Output is correct
48 Correct 38 ms 2808 KB Output is correct
49 Correct 39 ms 2812 KB Output is correct
50 Correct 34 ms 2808 KB Output is correct
51 Correct 36 ms 2936 KB Output is correct
52 Correct 41 ms 2936 KB Output is correct
53 Correct 39 ms 2936 KB Output is correct
54 Correct 32 ms 2808 KB Output is correct
55 Correct 40 ms 2808 KB Output is correct
56 Correct 31 ms 2808 KB Output is correct
57 Correct 33 ms 2936 KB Output is correct
58 Correct 33 ms 2936 KB Output is correct
59 Correct 24 ms 2040 KB Output is correct
60 Correct 31 ms 2808 KB Output is correct
61 Correct 30 ms 2808 KB Output is correct
62 Correct 28 ms 2936 KB Output is correct
63 Correct 29 ms 2808 KB Output is correct
64 Correct 29 ms 2808 KB Output is correct
65 Correct 29 ms 2808 KB Output is correct
66 Correct 29 ms 2808 KB Output is correct
67 Correct 29 ms 2808 KB Output is correct
68 Correct 31 ms 2808 KB Output is correct
69 Correct 29 ms 2808 KB Output is correct