Submission #278695

#TimeUsernameProblemLanguageResultExecution timeMemory
278695arnold518Circus (Balkan15_CIRCUS)C++14
0 / 100
4048 ms2192 KiB
#include "circus.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, M, P[MAXN+10]; int dp[MAXN+10]; void init(int _N, int _M, int _P[]) { N=_N; M=_M; for(int i=1; i<=N; i++) P[i]=_P[i-1]; sort(P+1, P+N+1); N=unique(P+1, P+N+1)-P-1; P[N+1]=M; dp[N+1]=0; for(int i=N; i>=1; i--) { dp[i]=2e9; for(int j=i+1; j<=N+1; j++) { if(dp[j]<=P[j]-P[i]) dp[i]=min(dp[i], P[j]-P[i]); } } } int minLength(int D) { int ans=2e9; for(int i=1; i<=N+1; i++) if(dp[i]<=abs(P[i]-D)) ans=min(ans, abs(P[i]-D)); return ans; }

Compilation message (stderr)

grader.cpp: In function 'int main()':
grader.cpp:14:12: warning: unused variable 'max_code' [-Wunused-variable]
   14 |  long long max_code;
      |            ^~~~~~~~
grader.cpp:16:7: 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:8: 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:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%d", &Q);
      |  ~~~~~^~~~~~~~~~
grader.cpp:23:8: 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...