Submission #200618

# Submission time Handle Problem Language Result Execution time Memory
200618 2020-02-07T16:10:08 Z gs18115 Sparklers (JOI17_sparklers) C++14
0 / 100
5 ms 376 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];
pl dp[1010][1010];
inline bool able(ll s)
{
    for(int i=0;i<n;i++)
        dp[i][i]=i==k-1?pl(x[i],x[i]):pl(INF,-INF);
    for(int l=1;l<n;l++)
    {
        for(int i=0;i+l<n;i++)
        {
            int j=i+l;
            dp[i][j].fi=min(x[j]-s*l,dp[i+1][j].fi-s);
            dp[i][j].se=max(x[i]+s*l,dp[i][j-1].se+s);
        }
    }
    return dp[0][n-1].fi<=dp[0][n-1].se;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t;
    cin>>n>>k>>t;
    for(int i=0;i<n;i++)
        cin>>x[i];
    ll s=1;
    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:47:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         ll m=s+e>>1;
              ~^~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -