# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
106952 |
2019-04-21T10:13:18 Z |
kek |
Gap (APIO16_gap) |
C++14 |
|
120 ms |
3828 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
// #define int ll
#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define debug(x) cout << #x << " = " << x << endl;
const int INF = 1e9 + 666;
template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
// void MinMax(ll, ll, ll*, ll*);
ll firstGroup(int);
ll secondGroup(int);
ll calc_ans(vector<ll> a) {
sort(all(a));
ll ans = 0;
for (int i = 0; i + 1 < len(a); ++i) {
cmax(ans, a[i + 1] - a[i]);
}
return ans;
}
ll findGap(int t, int n) {
if (t == 1) {
return firstGroup(n);
} else {
return secondGroup(n);
}
}
ll firstGroup(int n) {
vector<ll> a;
ll l = 0, r = 1e18;
while (len(a) < n) {
MinMax(l, r, &l, &r);
if (l == -1) {
break;
}
a.pb(l);
if (l != r) {
a.pb(r);
}
++l;
--r;
}
return calc_ans(a);
}
vector<ll> restore(ll l, ll r) {
if (l > r) {
return {};
}
MinMax(l, r, &l, &r);
if (l == -1) {
return {};
}
if (l == r) {
return {l};
}
ll m = (l + r) >> 1;
vector<ll> ans = {l, r};
for (auto &x : restore(l + 1, m)) {
ans.pb(x);
}
for (auto &x : restore(m + 1, r - 1)) {
ans.pb(x);
}
return ans;
}
ll secondGroup(int n) {
return calc_ans(restore(0, 1e18));
}
// void run();
// signed main() {
// iostream::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// run();
// }
// void run() {
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
1020 KB |
Output is correct |
17 |
Correct |
19 ms |
1020 KB |
Output is correct |
18 |
Correct |
19 ms |
1020 KB |
Output is correct |
19 |
Correct |
15 ms |
1148 KB |
Output is correct |
20 |
Correct |
13 ms |
1140 KB |
Output is correct |
21 |
Correct |
56 ms |
2796 KB |
Output is correct |
22 |
Correct |
74 ms |
2796 KB |
Output is correct |
23 |
Correct |
56 ms |
2796 KB |
Output is correct |
24 |
Correct |
65 ms |
2808 KB |
Output is correct |
25 |
Correct |
67 ms |
2924 KB |
Output is correct |
26 |
Correct |
63 ms |
2796 KB |
Output is correct |
27 |
Correct |
61 ms |
2888 KB |
Output is correct |
28 |
Correct |
56 ms |
2792 KB |
Output is correct |
29 |
Correct |
79 ms |
2796 KB |
Output is correct |
30 |
Correct |
40 ms |
2800 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Partially correct |
2 ms |
384 KB |
Partially correct |
3 |
Partially correct |
2 ms |
384 KB |
Partially correct |
4 |
Partially correct |
2 ms |
384 KB |
Partially correct |
5 |
Partially correct |
2 ms |
256 KB |
Partially correct |
6 |
Partially correct |
3 ms |
384 KB |
Partially correct |
7 |
Partially correct |
3 ms |
384 KB |
Partially correct |
8 |
Partially correct |
3 ms |
384 KB |
Partially correct |
9 |
Partially correct |
3 ms |
384 KB |
Partially correct |
10 |
Partially correct |
2 ms |
384 KB |
Partially correct |
11 |
Partially correct |
3 ms |
384 KB |
Partially correct |
12 |
Partially correct |
4 ms |
384 KB |
Partially correct |
13 |
Partially correct |
3 ms |
384 KB |
Partially correct |
14 |
Partially correct |
4 ms |
384 KB |
Partially correct |
15 |
Partially correct |
3 ms |
384 KB |
Partially correct |
16 |
Partially correct |
25 ms |
1096 KB |
Partially correct |
17 |
Partially correct |
27 ms |
1036 KB |
Partially correct |
18 |
Partially correct |
22 ms |
1024 KB |
Partially correct |
19 |
Partially correct |
28 ms |
1048 KB |
Partially correct |
20 |
Partially correct |
17 ms |
1144 KB |
Partially correct |
21 |
Partially correct |
94 ms |
3344 KB |
Partially correct |
22 |
Partially correct |
100 ms |
3368 KB |
Partially correct |
23 |
Partially correct |
106 ms |
3612 KB |
Partially correct |
24 |
Partially correct |
111 ms |
3548 KB |
Partially correct |
25 |
Partially correct |
91 ms |
3608 KB |
Partially correct |
26 |
Partially correct |
99 ms |
3556 KB |
Partially correct |
27 |
Partially correct |
99 ms |
3064 KB |
Partially correct |
28 |
Partially correct |
94 ms |
3532 KB |
Partially correct |
29 |
Partially correct |
120 ms |
3500 KB |
Partially correct |
30 |
Partially correct |
76 ms |
3828 KB |
Partially correct |
31 |
Partially correct |
2 ms |
384 KB |
Partially correct |
32 |
Partially correct |
2 ms |
384 KB |
Partially correct |