Submission #1006184

#TimeUsernameProblemLanguageResultExecution timeMemory
1006184lalig777Circus (Balkan15_CIRCUS)C++14
0 / 100
3420 ms2140 KiB
#include "circus.h" #include <iostream> #include <vector> #include <queue> #include <algorithm> #include <cmath> using namespace std; vector<int>minrope; vector<int>copiaP; int copiaN, copiaM; void init(int N, int M, int P[]){ copiaN=N; copiaM=M; copiaP.resize(N); for (int i=0; i<N; i++) copiaP[i]=P[i]; sort(copiaP.begin(), copiaP.end()); minrope.assign(N, 1e9); for (int i=0; i<N; i++) minrope[i]=M-copiaP[i]; for (int i=N-1; i>0; i--){ for (int j=i-1; j>=0; j--){ if (minrope[i]<=copiaP[i]-copiaP[j]) minrope[j]=min(minrope[j], copiaP[i]-copiaP[j]); } } } int minLength(int D){ int l=0, r=copiaN-1; int pos=copiaN; while (l<=r){ int m=(r-l)/2+l; if (copiaP[m]>=D){ r=m-1; pos=m; }else l=m+1; }int ans=copiaM-D; l=pos; r=copiaN-1; while (l<=r){ int m=(r-l)/2+l; if (minrope[m]<=copiaP[m]-D){ ans=copiaP[m]-D; r=m-1; }else l=m+1; }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...