Submission #371211

# Submission time Handle Problem Language Result Execution time Memory
371211 2021-02-26T06:11:26 Z ja_kingy Circus (Balkan15_CIRCUS) C++14
11 / 100
39 ms 3048 KB
#include "circus.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector<pii> mnstk;
vector<int> _P;
int N, M;

void init(int _N, int _M, int P[]){
    N = _N;
    M = _M;
    _P.insert(_P.end(), P, P+N);
}

int minLength(int D) {
    vector<int> P = _P;
    P.push_back(D);
    sort(P.begin(), P.end());
    priority_queue<pii> pq;
    mnstk.push_back({M,M});
    for (int i = N+1; i-->0;) {
        while (pq.size() && pq.top().first >= P[i]) {
            if (pq.top().second < mnstk.back().second) {
                mnstk.push_back(pq.top());
            }
            pq.pop();
        }
        pq.push({2*P[i] - mnstk.back().second, P[i]});
        if (P[i] == D) {
            return mnstk.back().second - P[i];
        }
    }
}

Compilation message

circus.cpp: In function 'int minLength(int)':
circus.cpp:16:21: warning: control reaches end of non-void function [-Wreturn-type]
   16 |     vector<int> P = _P;
      |                     ^~
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 Correct 32 ms 3044 KB Output is correct
2 Correct 32 ms 3048 KB Output is correct
3 Correct 32 ms 3044 KB Output is correct
4 Correct 39 ms 3044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3044 KB Output is correct
2 Correct 32 ms 3048 KB Output is correct
3 Correct 32 ms 3044 KB Output is correct
4 Correct 39 ms 3044 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3044 KB Output is correct
2 Correct 32 ms 3048 KB Output is correct
3 Correct 32 ms 3044 KB Output is correct
4 Correct 39 ms 3044 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -