Submission #282604

#TimeUsernameProblemLanguageResultExecution timeMemory
282604AaronNaiduGap (APIO16_gap)C++14
30 / 100
62 ms2340 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; /*void MinMax(ll left, ll right, ll *mn, ll *mx) { cout << left << " to " << right << "\n"; ll x, y; cin >> x >> y; *mn = x; *mx = y; }*/ ll findGap(int t, int n) { vector<ll> v; ll leftPointer = 0; ll rightPointer = 1000000000000000000; ll mn = 0; ll mx = 0; while (v.size() < n) { MinMax(leftPointer, rightPointer, &mn, &mx); v.push_back(mn); v.push_back(mx); leftPointer = mn+1; rightPointer = mx-1; } sort(v.begin(), v.end()); ll maxDiff = 0; for (int i = 0; i < v.size()-1; i++) { maxDiff = max(maxDiff, v[i+1]-v[i]); } return maxDiff; }

Compilation message (stderr)

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