Task: | Gap |
Sender: | Olli |
Submission time: | 2019-04-13 13:33:07 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'll findGap(int, int)': input/code.cpp:18:17: error: invalid type argument of unary '*' (have 'll {aka long long int}') MinMax(a, b, *mn, *mx); ^~ input/code.cpp:18:22: error: invalid type argument of unary '*' (have 'll {aka long long int}') MinMax(a, b, *mn, *mx); ^~ input/code.cpp:30:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(v.size() != n) { ~~~~~~~~~^~~~
Code
#include <iostream> #include "gap.h" #include <vector> #include <algorithm> using namespace std; typedef long long ll; ll findGap(int t, int n) { if(t == 2) return 0; ll a = 0; ll b = 1e18; vector<ll> v; ll mn, mx; mn = a; mx = b; while(mn != mx) { MinMax(a, b, *mn, *mx); if(mn == mx) { if(mn == -1) break; v.push_back(mn); } else { v.push_back(mn); v.push_back(mx); a = mn + 1; b = mx - 1; if(a > b) break; } } if(v.size() != n) { throw exception(); } sort(v.begin(), v.end()); ll ma = 0; for(int i = 0; i < n-1; ++i) { ma = max(ma, v[i+1] - v[i]); } return ma; }