# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
56869 |
2018-07-13T01:29:37 Z |
Benq |
Gap (APIO16_gap) |
C++14 |
|
96 ms |
39900 KB |
#include "gap.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 30001;
ll solve1(int N) {
ll l = 0, r = 1e18;
ll mn,mx;
vl v;
while (N) {
MinMax(l,r,&mn,&mx);
v.pb(mn); N --;
if (N) {
v.pb(mx); N --;
}
l = mn+1, r = mx-1;
}
sort(all(v));
ll ans = 0;
F0R(i,sz(v)-1) ans = max(ans,v[i+1]-v[i]);
return ans;
}
ll cdiv(ll a, ll b) {
return (a+b-1)/b;
}
ll solve2(int N) {
ll mn,mx;
MinMax(0,(ll)1e18,&mn,&mx);
ll dif = cdiv(mx-mn,N-1);
vpl v;
while (mn <= mx) {
ll a,b;
if (mn == mx) {
a = b = mn;
} else {
MinMax(mn, mn+dif-1,&a,&b);
}
if (a != -1) v.pb({a,b});
mn += dif;
}
ll ans = dif;
F0R(i,sz(v)-1) ans = max(ans,v[i+1].f-v[i].s);
return ans;
}
long long findGap(int T, int N) {
if (T == 1) return solve1(N);
return solve2(N);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
528 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
700 KB |
Output is correct |
5 |
Correct |
2 ms |
708 KB |
Output is correct |
6 |
Correct |
2 ms |
880 KB |
Output is correct |
7 |
Correct |
2 ms |
880 KB |
Output is correct |
8 |
Correct |
2 ms |
880 KB |
Output is correct |
9 |
Correct |
2 ms |
880 KB |
Output is correct |
10 |
Correct |
2 ms |
880 KB |
Output is correct |
11 |
Correct |
4 ms |
880 KB |
Output is correct |
12 |
Correct |
3 ms |
912 KB |
Output is correct |
13 |
Correct |
3 ms |
928 KB |
Output is correct |
14 |
Correct |
4 ms |
948 KB |
Output is correct |
15 |
Correct |
3 ms |
1120 KB |
Output is correct |
16 |
Correct |
20 ms |
2260 KB |
Output is correct |
17 |
Correct |
17 ms |
2568 KB |
Output is correct |
18 |
Correct |
21 ms |
3032 KB |
Output is correct |
19 |
Correct |
17 ms |
3508 KB |
Output is correct |
20 |
Correct |
16 ms |
3600 KB |
Output is correct |
21 |
Correct |
68 ms |
6880 KB |
Output is correct |
22 |
Correct |
64 ms |
8728 KB |
Output is correct |
23 |
Correct |
79 ms |
10492 KB |
Output is correct |
24 |
Correct |
71 ms |
12392 KB |
Output is correct |
25 |
Correct |
53 ms |
13560 KB |
Output is correct |
26 |
Correct |
61 ms |
15408 KB |
Output is correct |
27 |
Correct |
68 ms |
17376 KB |
Output is correct |
28 |
Correct |
69 ms |
19272 KB |
Output is correct |
29 |
Correct |
80 ms |
21080 KB |
Output is correct |
30 |
Correct |
53 ms |
21708 KB |
Output is correct |
31 |
Correct |
2 ms |
21708 KB |
Output is correct |
32 |
Correct |
2 ms |
21708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
21708 KB |
Output is correct |
2 |
Correct |
2 ms |
21708 KB |
Output is correct |
3 |
Correct |
3 ms |
21708 KB |
Output is correct |
4 |
Correct |
2 ms |
21708 KB |
Output is correct |
5 |
Correct |
2 ms |
21708 KB |
Output is correct |
6 |
Correct |
3 ms |
21708 KB |
Output is correct |
7 |
Correct |
3 ms |
21708 KB |
Output is correct |
8 |
Correct |
3 ms |
21708 KB |
Output is correct |
9 |
Correct |
2 ms |
21708 KB |
Output is correct |
10 |
Correct |
2 ms |
21708 KB |
Output is correct |
11 |
Correct |
4 ms |
21708 KB |
Output is correct |
12 |
Correct |
3 ms |
21708 KB |
Output is correct |
13 |
Correct |
4 ms |
21708 KB |
Output is correct |
14 |
Correct |
4 ms |
21708 KB |
Output is correct |
15 |
Correct |
4 ms |
21708 KB |
Output is correct |
16 |
Correct |
24 ms |
21708 KB |
Output is correct |
17 |
Correct |
22 ms |
21708 KB |
Output is correct |
18 |
Correct |
21 ms |
21880 KB |
Output is correct |
19 |
Correct |
22 ms |
22420 KB |
Output is correct |
20 |
Correct |
11 ms |
22420 KB |
Output is correct |
21 |
Correct |
87 ms |
25684 KB |
Output is correct |
22 |
Correct |
96 ms |
27604 KB |
Output is correct |
23 |
Correct |
80 ms |
29388 KB |
Output is correct |
24 |
Correct |
88 ms |
31232 KB |
Output is correct |
25 |
Correct |
80 ms |
33584 KB |
Output is correct |
26 |
Correct |
84 ms |
34292 KB |
Output is correct |
27 |
Correct |
81 ms |
36192 KB |
Output is correct |
28 |
Correct |
80 ms |
37996 KB |
Output is correct |
29 |
Correct |
88 ms |
39840 KB |
Output is correct |
30 |
Correct |
52 ms |
39900 KB |
Output is correct |
31 |
Correct |
3 ms |
39900 KB |
Output is correct |
32 |
Correct |
3 ms |
39900 KB |
Output is correct |