답안 #1047302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1047302 2024-08-07T11:52:33 Z PanosPask Circus (Balkan15_CIRCUS) C++14
49 / 100
1801 ms 524288 KB
#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

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 1333 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 25 ms 2512 KB Output is correct
6 Correct 44 ms 6232 KB Output is correct
7 Correct 26 ms 2508 KB Output is correct
8 Correct 22 ms 2512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 25 ms 2512 KB Output is correct
6 Correct 44 ms 6232 KB Output is correct
7 Correct 26 ms 2508 KB Output is correct
8 Correct 22 ms 2512 KB Output is correct
9 Correct 1801 ms 17884 KB Output is correct
10 Correct 1771 ms 10672 KB Output is correct
11 Correct 1728 ms 10108 KB Output is correct
12 Correct 1709 ms 18864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1333 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1333 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -