제출 #502967

#제출 시각아이디문제언어결과실행 시간메모리
502967dooweyGap (APIO16_gap)C++14
100 / 100
52 ms3216 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair long long findGap(int T, int N){ if(T == 1){ ll low = -1, high = (ll)1e18 + 1; vector<ll> C(N); int L = 0, R = N - 1; for(int i = 0 ; i < (N + 1) / 2; i ++ ){ MinMax(low + 1, high - 1, &low, &high); C[L] = low; C[R] = high; L ++ ; R -- ; } ll res = 0; for(int i = 1; i < N; i ++ ){ res = max(res, C[i] - C[i - 1]); } return res; } ll low=0, high=0; ll lim = (ll)1e18; MinMax(0ll, lim, &low, &high); ll S = (high - low + (N - 1) - 1) / (N - 1); // the gap is atleast S ll gl = low + 1; ll gr; vector<ll> in; in.push_back(low); if(N >= 3){ ll ca, cb; while(gl <= high){ gr = min(high - 1, gl + S); MinMax(gl, gr, &ca, &cb); gl += S + 1; if(ca == -1) continue; in.push_back(ca); in.push_back(cb); } } in.push_back(high); ll res = 0; for(int i = 1; i < in.size(); i ++ ){ res = max(res, in[i] - in[i - 1]); } return res; }

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

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