답안 #200663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200663 2020-02-08T01:25:25 Z gs18115 Sparklers (JOI17_sparklers) C++14
100 / 100
40 ms 2936 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k;
ll x[100010];
inline bool able(ll sp)
{
    vector<ll>v(n);
    for(int i=0;i<n;i++)
        v[i]=x[i]-sp*i*2;
    int l=k,r=k;
    ll lm=v[l],rm=v[r];
    for(int i=0;i<n;i++)
    {
        while(l>0&&v[l-1]>=rm)
            lm=max(lm,v[--l]);
        while(r<n-1&&v[r+1]<=lm)
            rm=min(rm,v[++r]);
    }
    if(r-l<n-1)
        return 0;
    lm=v[l=0];
    rm=v[r=n-1];
    if(lm<rm)
        return 0;
    for(int i=0;i<n;i++)
    {
        while(l<k&&v[l+1]>=rm)
            lm=max(lm,v[++l]);
        while(r>k&&v[r-1]<=lm)
            rm=min(rm,v[--r]);
    }
    return l==r;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t;
    cin>>n>>k>>t;
    k--;
    for(int i=0;i<n;i++)
        cin>>x[i];
    ll s=0;
    ll e=inf;
    while(s<e)
    {
        ll m=s+e>>1;
        if(able(m))
            e=m;
        else
            s=m+1;
    }
    cout<<(s+t-1)/t<<endl;
    return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:61:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         ll m=s+e>>1;
              ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 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 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 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 380 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 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 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 380 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 5 ms 376 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 380 KB Output is correct
40 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 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 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 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 380 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 5 ms 376 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 380 KB Output is correct
40 Correct 6 ms 376 KB Output is correct
41 Correct 26 ms 2040 KB Output is correct
42 Correct 6 ms 376 KB Output is correct
43 Correct 12 ms 888 KB Output is correct
44 Correct 37 ms 2908 KB Output is correct
45 Correct 35 ms 2908 KB Output is correct
46 Correct 38 ms 2904 KB Output is correct
47 Correct 38 ms 2936 KB Output is correct
48 Correct 36 ms 2808 KB Output is correct
49 Correct 40 ms 2904 KB Output is correct
50 Correct 37 ms 2936 KB Output is correct
51 Correct 37 ms 2908 KB Output is correct
52 Correct 36 ms 2904 KB Output is correct
53 Correct 38 ms 2908 KB Output is correct
54 Correct 35 ms 2908 KB Output is correct
55 Correct 34 ms 2904 KB Output is correct
56 Correct 36 ms 2908 KB Output is correct
57 Correct 36 ms 2832 KB Output is correct
58 Correct 37 ms 2936 KB Output is correct
59 Correct 27 ms 2136 KB Output is correct
60 Correct 35 ms 2904 KB Output is correct
61 Correct 36 ms 2808 KB Output is correct
62 Correct 35 ms 2908 KB Output is correct
63 Correct 34 ms 2808 KB Output is correct
64 Correct 36 ms 2908 KB Output is correct
65 Correct 36 ms 2812 KB Output is correct
66 Correct 35 ms 2808 KB Output is correct
67 Correct 36 ms 2908 KB Output is correct
68 Correct 35 ms 2936 KB Output is correct
69 Correct 34 ms 2904 KB Output is correct