제출 #21918

#제출 시각아이디문제언어결과실행 시간메모리
21918sampritiGap (APIO16_gap)C++14
70 / 100
89 ms8220 KiB
#include "gap.h" #include <climits> #include <vector> #include <cassert> using namespace std; long long findGap(int T, int N) { long long L, R; MinMax(0, LLONG_MAX, &L, &R); if(T == 1) { vector<long long> A, B; A.push_back(L); B.push_back(R); while(true) { long long qL, qR; MinMax(L + 1, R - 1, &qL, &qR); if(qL == -1) break; A.push_back(qL); B.push_back(qR); if(qL == qR) break; L = qL, R = qR; } A.insert(A.end(), B.rbegin(), B.rend()); assert(A.size() == N); long long ans = 0; for(int i = 1; i < N; i++) { ans = max(ans, A[i] - A[i - 1]); } return ans; } long long diff = ((R - L - 1) + (N - 2))/(N - 1); vector<pair<long long, long long> > cands; cands.push_back({L, L}); for(long long x = L + 1; x <= R - 1; x += diff) { long long qL, qR; MinMax(x, min(x + diff - 1, R - 1), &qL, &qR); if(qL != -1) cands.push_back({qL, qR}); } cands.push_back({R, R}); long long ans = 0; for(int i = 1; i < cands.size(); i++) { ans = max(ans, cands[i].first - cands[i - 1].second); } return ans; }

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

In file included from /usr/include/c++/5/cassert:43:0,
                 from gap.cpp:5:
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     assert(A.size() == N);
                     ^
gap.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 1; i < cands.size(); i++) {
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...