Submission #1148826

#TimeUsernameProblemLanguageResultExecution timeMemory
1148826kitkat12Circus (Balkan15_CIRCUS)C++20
0 / 100
13 ms1212 KiB
#include <bits/stdc++.h>
#include "circus.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define debug(x) std::cout << #x << ": " << x << "\n"
#define all(v) v.begin(), v.end()
#define li(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define endl '\n'
#define mem(name,val) memset(name,val,sizeof(name))
#define min(a,b) (a<=b ? a : b)
#define max(a,b) (a>=b ? a : b)
//using u64 = uint64_t;
//using u128 = __uint128_t;

const int nmax = 2003;
const ll inf = 1e18;
vector<ll> dp(nmax,inf);
vector<int> p;
int n,m; 

void init(int N, int M, int P[]){
    n = N; m = M;
    sort(P,P+N);
    li(i,0,n)p.pb(P[i]);
    dp[n-1] = m-p[n-1];
    for(int i = n-2; i>=0; i--){
        dp[i] = abs(p[i]-m);
        for(int j = i+1; j<n; j++){
            dp[i]=min(dp[i],max(dp[j],abs(p[i]-p[j])));
        }
    }
}

int minLength(int d){
    int idx = lower_bound(all(p),d) - p.begin();
    ll res = abs(d-m);
    li(i,idx,n){
        if(abs(p[i]-d)<dp[i]) continue;
        res = min(res, max(abs(p[i]-d), dp[i]));
    }
    return res;
}

Compilation message (stderr)

grader.cpp: In function 'int main()':
grader.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d%d", &N, &M);
      |         ~~~~~^~~~~~~~~~~~~~~~
grader.cpp:18:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |                 scanf("%d", &P[i]);
      |                 ~~~~~^~~~~~~~~~~~~
grader.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d", &Q);
      |         ~~~~~^~~~~~~~~~
grader.cpp:23:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |                 scanf("%d", &d);
      |                 ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...