Submission #1047230

# Submission time Handle Problem Language Result Execution time Memory
1047230 2024-08-07T11:06:55 Z PanosPask Circus (Balkan15_CIRCUS) C++14
0 / 100
4000 ms 2140 KB
#include <bits/stdc++.h>
#include "circus.h"

using namespace std;

int N, M;
vector<int> p;
vector<int> minlen;

void init(int n, int m, int P[]){
    N = n;
    M = m;

    p.resize(N);
    minlen.resize(N);
    
    for (int i = 0; i < N; i++) {
        p[i] = P[i];
    }

    sort(p.begin(), p.end());
    for (int i = N - 1; i >= 0; i--) {
        minlen[i] = M - p[i];

        for (int j = i + 1; j < N; j++) {
            if (p[j] - p[i] >= minlen[j]) {
                minlen[i] = min(minlen[i], p[j] - p[i]);
            }
        }
    }
}
int minLength(int D) {
    int pos = lower_bound(p.begin(), p.end(), D) - p.begin();

    int ans = M - D;
    for (int i = pos; i < N; i++) {
        if (p[i] - D >= minlen[i]) {
            ans = min(ans, p[i] - D);
        }
    }

    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 Execution timed out 4070 ms 2140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 2140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 2140 KB Time limit exceeded
2 Halted 0 ms 0 KB -