제출 #586633

#제출 시각아이디문제언어결과실행 시간메모리
586633GioChkhaidzeGap (APIO16_gap)C++14
89.04 / 100
62 ms3268 KiB
#include "gap.h" #include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int Nn = 1e5 + 5; ll a[Nn]; long long findGap(int T, int N) { ll ans = 0; if (T == 1) { ll Mn = -1, Mx = -1, l = 0, r = N - 1; MinMax(0ll, 1000000000000000000ll, &Mn, &Mx); a[l] = Mn, a[r] = Mx; while (l + 1 < r) { MinMax(a[l] + 1, a[r] - 1, &Mn, &Mx); if (Mn == -1 && Mx == -1) { break; } a[++l] = Mn; a[--r] = Mx; } for (int i = 1; i < N; ++i) { ans = max(ans, a[i] - a[i - 1]); } } else if (T == 2) { vector < ll > s; ll Mn = -1, Mx = -1, l = 0, r = N - 1; MinMax(0ll, 1000000000000000000ll, &Mn, &Mx); ll A = Mn, B = Mx; ll len = (Mx - Mn + 1) / N; s.pb(A); for (ll i = A; i < B; i += len) { MinMax(i + 1, min(i + len, B - 1), &Mn, &Mx); if (Mn == -1 && Mx == -1) continue; s.pb(Mn), s.pb(Mx); } s.pb(B); for (int i = 1; i < s.size(); ++i) { ans = max(ans, s[i] - s[i - 1]); } } return ans; }

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for (int i = 1; i < s.size(); ++i) {
      |                   ~~^~~~~~~~~~
gap.cpp:34:24: warning: unused variable 'l' [-Wunused-variable]
   34 |   ll Mn = -1, Mx = -1, l = 0, r = N - 1;
      |                        ^
gap.cpp:34:31: warning: unused variable 'r' [-Wunused-variable]
   34 |   ll Mn = -1, Mx = -1, l = 0, r = N - 1;
      |                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...