답안 #275859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
275859 2020-08-20T08:04:12 Z 최은수(#5098) Circus (Balkan15_CIRCUS) C++17
0 / 100
4000 ms 1888 KB
#include"circus.h"
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
static int n,m;
static vector<int>p;
static int cal[100010];
static int cal2[100010];
//static int pmn[100010];
void init(int N,int M,int P[])
{
    n=N,m=M;
    for(int i=0;i<n;i++)
        p.eb(P[i]);
    sort(all(p));
    p.erase(unique(all(p)),p.end());
    n=p.size();
    p.eb(m);
    cal[n]=0;
    for(int i=n;i-->0;)
    {
        int s=i+1,e=n;
        while(s<e)
        {
            int m=s+(e-s)/2;
            if(p[m]-p[i]>=cal[m])
                e=m;
            else
                s=m+1;
        }
        cal[i]=p[s]-p[i];
    }
    for(int i=0;i<n;i++)
    {
        cal2[i]=cal[i];
        for(int j=0;j<i;j++)
            if(p[i]-p[j]>=cal2[j])
                cal2[i]=min(cal2[i],p[i]-p[j]);
    }
    return;
}
int minLength(int D)
{
    int d=D;
    //int pos=upper_bound(all(p),d)-p.begin();
    int ans=m-d;
    for(int i=0;i<n;i++)
        if(abs(d-p[i])>=cal2[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 Execution timed out 4053 ms 1888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4053 ms 1888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4053 ms 1888 KB Time limit exceeded
2 Halted 0 ms 0 KB -