Submission #1047302

#TimeUsernameProblemLanguageResultExecution timeMemory
1047302PanosPaskCircus (Balkan15_CIRCUS)C++14
49 / 100
1801 ms524288 KiB
#include <bits/stdc++.h> #include "circus.h" #define mp make_pair using namespace std; typedef pair<int, int> pi; int N, M; vector<int> p; vector<int> dist; void init(int n, int m, int P[]){ N = n; M = m; p.resize(N); dist.resize(N); for (int i = 0; i < N; i++) { p[i] = P[i]; } sort(p.begin(), p.end()); priority_queue<pi, vector<pi>, greater<pi>> q; for (int i = 0; i < N; i++) { dist[i] = M - p[i]; q.push(mp(dist[i], i)); } while (!q.empty()) { int i, d; tie(d, i) = q.top(); q.pop(); if (dist[i] < d) { continue; } for (int j = 0; j < N; j++) { if (abs(p[j] - p[i]) >= dist[i] && dist[j] > abs(p[j] - p[i])) { dist[j] = abs(p[j] - p[i]); q.push(mp(dist[j], j)); } } } } int minLength(int D) { int ans = M - D; for (int i = 0; i < N; i++) { if (abs(D - p[i]) >= dist[i]) { ans = min(ans, abs(D - p[i])); } } 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...