Submission #329476

#TimeUsernameProblemLanguageResultExecution timeMemory
329476dolphingarlicCircus (Balkan15_CIRCUS)C++14
0 / 100
45 ms11096 KiB
#include "circus.h" #include <bits/stdc++.h> using namespace std; int n, m, p[100000], mn[100000]; void init(int N, int M, int P[]){ n = N, m = M; memcpy(p, P, sizeof p); sort(p, p + n); priority_queue<pair<int, int>> pq; for (int i = 0; i < n; i++) pq.push({p[i] - m, i}); int tmp = n; while (pq.size()) { int cost, curr; tie(cost, curr) = pq.top(); pq.pop(); if (!mn[curr]) { assert(curr == --tmp); mn[curr] = -cost; for (int i = 0; i < n; i++) if (!mn[i] && abs(p[curr] - p[i]) >= -cost) { pq.push({-abs(p[curr] - p[i]), i}); } } } } int minLength(int D) { int ans = m - D; for (int i = 0; i < n; i++) if (abs(D - p[i]) >= mn[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...