Submission #582110

# Submission time Handle Problem Language Result Execution time Memory
582110 2022-06-23T11:43:36 Z urd05 Sparklers (JOI17_sparklers) C++17
0 / 100
5 ms 4180 KB
#include <bits/stdc++.h>
using namespace std;
 
int n,k,t;
long long arr[100000];
int dp[1000][1000];
long long s;
 
int ans(int l,int r) {
    if (l==0&&r==n-1) {
        return 1;
    }
    if (dp[l][r]!=-1) {
        return dp[l][r];
    }
    int ret=0;
    if (l!=0&&(arr[r]-arr[l-1])/s>=2*t*(r-l+1)){
        ret|=ans(l-1,r);
    }
    if (r!=n-1&&(arr[r+1]-arr[l])/s>=2*t*(r-l+1)) {
        ret|=ans(l,r+1);
    }
    return dp[l][r]=ret;
}
 
bool isp(long long x) {
    s=x;
    memset(dp,-1,sizeof(dp));
    return ans(k,k);
}
 
int main(void) {
    scanf("%d %d %d",&n,&k,&t);
    k--;
    for(int i=0;i<n;i++){
        scanf("%lld",&arr[i]);
    }
    long long lo=0;
    long long hi=1e9; //possible
    while (lo+1<hi) {
        long long mid=(lo+hi)/2;
        if (isp(mid)) {
            hi=mid;
        }
        else {
            lo=mid;
        }
    }
    printf("%lld",hi);
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d %d %d",&n,&k,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%lld",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -