QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#200826 | #4. Gap | _LAP_ | 0 | 0ms | 3664kb | C++14 | 981b | 2023-10-04 20:55:12 | 2023-10-04 20:55:12 |
answer
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int n) {
vector<long long> a(n + 1);
long long mn[2], mx[2];
int i;
for(i = 1; i + 2 <= n; i += 3) {
MinMax(i, i + 1, &mn[0], &mx[0]);
if(mn[0] == mx[0]) {
a[i] = a[i + 1] = mn[0];
i --; continue;
} else {
MinMax(i + 1, i + 2, &mn[1], &mx[1]);
if(mn[1] == mx[1]) {
a[i + 1] = a[i + 2] = mn[1];
a[i] = mn[0] + mx[0] - mn[1];
} else {
if(mn[0] == mn[1] || mn[0] == mx[1]) {
a[i + 1] = mn[0];
} else a[i + 1] = mx[0];
a[i] = mn[0] + mx[0] - a[i + 1];
a[i + 2] = mn[1] + mx[1] - a[i + 1];
}
}
}
if(i + 1 == n) {
MinMax(i, i, &mn[0], &mx[0]);
a[i] = mn[0];
MinMax(i + 1, i + 1, &mn[0], &mx[0]);
a[i + 1] = mn[0];
} else if(i == n) {
MinMax(i, i, &mn[0], &mx[0]);
a[i] = mn[0];
}
long long r = a[2] - a[1];
for(int i = 3; i <= n; i ++)
r = max(r, a[i] - a[i - 1]);
return r;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3664kb
input:
1 2 29659227736649406 728704890713443211
output:
0 2
result:
wrong answer returned 0 but expected 699045662976793805
Subtask #2:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 0ms
memory: 3652kb
input:
2 2 78103569500113815 605712887753065418
output:
0 2
result:
wrong answer returned 0 but expected 527609318252951603