Submission #329477

# Submission time Handle Problem Language Result Execution time Memory
329477 2020-11-21T09:49:46 Z dolphingarlic Circus (Balkan15_CIRCUS) C++14
49 / 100
3415 ms 524292 KB
#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});
    while (pq.size()) {
        int cost, curr;
        tie(cost, curr) = pq.top();
        pq.pop();
        if (!mn[curr]) {
            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

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 time Memory Grader output
1 Runtime error 1101 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 498 ms 17360 KB Output is correct
6 Correct 499 ms 17360 KB Output is correct
7 Correct 480 ms 17504 KB Output is correct
8 Correct 472 ms 17360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 498 ms 17360 KB Output is correct
6 Correct 499 ms 17360 KB Output is correct
7 Correct 480 ms 17504 KB Output is correct
8 Correct 472 ms 17360 KB Output is correct
9 Correct 3415 ms 18412 KB Output is correct
10 Correct 3393 ms 17352 KB Output is correct
11 Correct 3384 ms 17364 KB Output is correct
12 Correct 3385 ms 19480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1101 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1101 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -