Submission #95555

#TimeUsernameProblemLanguageResultExecution timeMemory
95555hihiGap (APIO16_gap)C++11
100 / 100
66 ms4212 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; long long findGap(int T, int N) { long long min, maxi; if (T == 1) { vector<long long> a; MinMax(0, (long long)1012345678901234567, &min, &maxi); for (int i = 0; i < (N-1)/2; i++) { a.push_back(min); a.push_back(maxi); long long temp = min+1; long long temp2 = maxi-1; MinMax(temp, temp2, &min, &maxi); } if (N%2==0) { a.push_back(min); a.push_back(maxi); } else { a.push_back(min); } sort(a.begin(), a.end()); long long gap = 0; for (int i = 1; i < a.size(); i++) { gap = max(a[i] - a[i-1], gap); } return gap; } else { MinMax(0, (long long)1012345678901234567, &min, &maxi); long long gap = 0; vector<long long> a; long long dis = ceil((maxi - min )/((long double)N-1) + 1); long long min2 = min, max2 = (min + dis); for (int i = 0; i < N-1; i++) { MinMax(min2, max2, &min, &maxi); if (min == maxi && min != -1) { a.push_back(min); } else if (min != maxi) { a.push_back(min); a.push_back(maxi); } min2 = max2+1; max2 += dis; } for (int i = 1; i < a.size(); i++) { gap = max(a[i] - a[i-1], gap); } return gap; } }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < a.size(); i++) {
                         ~~^~~~~~~~~~
gap.cpp:50:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for (int i = 1; i < a.size(); i++) {
                      ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...