답안 #329476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329476 2020-11-21T09:48:43 Z dolphingarlic Circus (Balkan15_CIRCUS) C++14
0 / 100
45 ms 11096 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});
    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

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);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 45 ms 11096 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1260 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1260 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1260 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 45 ms 11096 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 45 ms 11096 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -