제출 #521138

#제출 시각아이디문제언어결과실행 시간메모리
521138JomnoiGap (APIO16_gap)C++17
30 / 100
73 ms3200 KiB
#include <bits/stdc++.h>
#include "gap.h"
#define DEBUG 0
using namespace std;

const long long INF = 1e18;

long long findGap(int T, int N) {
    vector <long long> a;
    if(T == 1) {
        a.resize(N);
        MinMax(0, INF, &a[0], &a[N - 1]);
        int l = 1, r = N - 2;
        while(l <= r) {
            MinMax(a[l - 1] + 1, a[r + 1] - 1, &a[l], &a[r]);
            l++;
            r--;
        }
    }
    else {
        long long L, R;
        MinMax(0, INF, &L, &R);
        long long minimum = (R - L) / (N - 1);
        L++;
        while(L < R) {
            long long nL, nR;
            MinMax(L, L + minimum, &nL, &nR);
            if(nL != -1 and nR != -1) {
                a.push_back(nL);
                a.push_back(nR);
            }

            L += minimum;
        }
    }

    long long ans = 0;
    for(int i = 1; i < a.size(); i++) {
        ans = max(ans, a[i] - a[i - 1]);
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 1; i < a.size(); i++) {
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...