답안 #1006184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006184 2024-06-23T14:05:07 Z lalig777 Circus (Balkan15_CIRCUS) C++14
0 / 100
3420 ms 2140 KB
#include "circus.h"
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

vector<int>minrope;
vector<int>copiaP;
int copiaN, copiaM;

void init(int N, int M, int P[]){
    copiaN=N;
    copiaM=M;
    copiaP.resize(N);
    for (int i=0; i<N; i++) copiaP[i]=P[i];
    sort(copiaP.begin(), copiaP.end());
    minrope.assign(N, 1e9);
    for (int i=0; i<N; i++) minrope[i]=M-copiaP[i];
    for (int i=N-1; i>0; i--){
        for (int j=i-1; j>=0; j--){
            if (minrope[i]<=copiaP[i]-copiaP[j]) minrope[j]=min(minrope[j], copiaP[i]-copiaP[j]);
        }
    }
}

int minLength(int D){
    int l=0, r=copiaN-1;
    int pos=copiaN;
    while (l<=r){
        int m=(r-l)/2+l;
        if (copiaP[m]>=D){
            r=m-1;
            pos=m;
        }else l=m+1;
    }int ans=copiaM-D;
    l=pos; r=copiaN-1;
    while (l<=r){
        int m=(r-l)/2+l;
        if (minrope[m]<=copiaP[m]-D){
            ans=copiaP[m]-D;
            r=m-1;
        }else l=m+1;
    }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 Incorrect 3420 ms 2140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3420 ms 2140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3420 ms 2140 KB Output isn't correct
2 Halted 0 ms 0 KB -