답안 #670824

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670824 2022-12-10T18:15:43 Z finn__ Circus (Balkan15_CIRCUS) C++17
0 / 100
185 ms 3016 KB
#include "circus.h"
#include <bits/stdc++.h>
using namespace std;

vector<int64_t> p;
vector<int64_t> dp;

int64_t min_height(int64_t d)
{
    int64_t a = 0, b = 1e18;

    while (a < b)
    {
        int64_t mid = (a + b) / 2;
        size_t j = upper_bound(p.begin(), p.end(), d + mid) - p.begin() - 1;
        if (dp[j] <= p[j] - d)
            b = mid;
        else
            a = mid + 1;
    }

    return a;
}

void init(int N, int M, int P[])
{
    p = vector<int64_t>(N + 1);
    dp = vector<int64_t>(N + 1);
    p[N] = M;
    dp[N] = 0;
    copy(P, P + N, p.begin());
    sort(p.begin(), p.end());

    for (size_t i = 0; i < N + 1; i++)
        dp[i] = max((int64_t)0, M - p[i]);

    for (size_t i = N - 1; i < N; i--)
        dp[i] = min_height(p[i]);
}

int minLength(int D)
{
    return min_height(D);
}

Compilation message

circus.cpp: In function 'void init(int, int, int*)':
circus.cpp:34:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     for (size_t i = 0; i < N + 1; i++)
      |                        ~~^~~~~~~
circus.cpp:37:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     for (size_t i = N - 1; i < N; i--)
      |                            ~~^~~
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 185 ms 3016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 185 ms 3016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 185 ms 3016 KB Output isn't correct
2 Halted 0 ms 0 KB -