Submission #106188

#TimeUsernameProblemLanguageResultExecution timeMemory
106188OpenTheWindowGap (APIO16_gap)C++14
30 / 100
115 ms2304 KiB
#include<iostream> #include<string> #include<set> #include<utility> #include<vector> #include<map> #include<algorithm> #include<queue> #include<stack> #include"gap.h" using namespace std; long long findGap(int T, int N){ long long ans = 0; if(T == 1){ vector<long long> a; long long s = 0, t = 1000000000000000000LL; while (true) { long long mn, mx; if(a.size() == N) break; if(s > t) break; MinMax(s, t, &mn, &mx); if(mn == -1) break; if(mn < mx){ a.push_back(mn); a.push_back(mx); s = mn + 1; t = mx - 1; } if(mn == mx){ a.push_back(mn); break; } } sort(a.begin(), a.end()); ans = 0; for(int i=0; i<N-1; i++){ ans = max(ans, a[i+1] - a[i]); } } else{ vector<long long> a; long long ms = 0, mt = 1000000000000000000LL; long long mn, mx; /* MinMax(ms, mt, &mn, &mx); a.push_back(mn); a.push_back(mx); */ long long s = 0, t = 1; while (true) { if(a.size() == N) break; MinMax(s, t, &mn, &mx); if(mn < mx){ a.push_back(mn); a.push_back(mx); } if(mn == mx){ a.push_back(mn); } s = t + 1; t = s + 2; } sort(a.begin(), a.end()); ans = 0; for(int i=0; i<N-1; i++){ ans = max(ans, a[i+1] - a[i]); } } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(a.size() == N) break;
       ~~~~~~~~~^~~~
gap.cpp:75:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(a.size() == N) break;
       ~~~~~~~~~^~~~
gap.cpp:62:13: warning: unused variable 'ms' [-Wunused-variable]
   long long ms = 0, mt = 1000000000000000000LL;
             ^~
gap.cpp:62:21: warning: unused variable 'mt' [-Wunused-variable]
   long long ms = 0, mt = 1000000000000000000LL;
                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...