QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202159 | #4. Gap | _LAP_ | Compile Error | / | / | C++14 | 889b | 2023-10-05 20:22:18 | 2023-10-05 20:22:18 |
Judging History
answer
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int n) {
if(T == 1) {
vector<long long> a(n + 1);
long long mn, mx, L = 0, R = 1e18;
int l = 1, r = n;
while(l <= r) {
MinMax(L, R, &mn, &mx);
a[l ++] = mn; if(l <= r) a[r --] = mx;
L = mn + 1, R = mx - 1;
}
long long res = 0;
for(int i = 2; i <= n; i ++) res = max(res, a[i] - a[i - 1]);
return res;
} else {
long long mn, mx; MinMax(0ll, (long long)1e18, &mn, &mx);
long long k = (mx - mn) / (n - 1); if((mx - mn) % (n - 1)) k ++;
long long lst = mn; long long Maxv = mx;
for(long long i = mn + 1; i < Maxv; i += k) {
long long r = min(i + k - 1, Maxv - 1); MinMax(i, r, &mn, &mx);
ans = max(ans, l - lst); if(mx > 0) lst = mx;
}
ans = max(ans, Maxv - lst); return ans;
}
}
Details
answer.code: In function ‘long long int findGap(int, int)’: answer.code:26:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 26 | ans = max(ans, l - lst); if(mx > 0) lst = mx; | ^~~ | abs answer.code:26:28: error: ‘l’ was not declared in this scope 26 | ans = max(ans, l - lst); if(mx > 0) lst = mx; | ^ answer.code:28:9: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 28 | ans = max(ans, Maxv - lst); return ans; | ^~~ | abs