답안 #693096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
693096 2023-02-02T11:29:25 Z josanneo22 Gap (APIO16_gap) C++17
30 / 100
44 ms 1872 KB
#include<bits/stdc++.h>
#include<iostream>
#include<stdlib.h>
#include<cmath>
#include <algorithm>
#include<numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define trav(a,x) for (auto& a: x)
#define fr(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>=(b); i+=(s))
#define fr1(e) fr(i, 0, e, 1)
#define fr2(i, e) fr(i, 0, e, 1)
#define fr3(i, b, e) fr(i, b, e, 1)
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define in insert
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, 1, 0, -1 };
const int mod = 1e9 + 7;

void xd(string str)
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (str != "")
	{
		//freopen((str + ".in").c_str(), "r", stdin);
		//freopen((str + ".out").c_str(), "w", stdout);
	}
}
int add(int a, int b, int mod = 1e9 + 7) { return (((a % mod) + (b % mod)) + mod) % mod; }
int sub(int a, int b, int mod = 1e9 + 7) { return (((a % mod) - (b % mod)) + mod) % mod; }
int mul(int a, int b, int mod = 1e9 + 7) { return (((a % mod) * (b % mod)) + mod) % mod; }
int bin(int a, int b, int mod = 1e9 + 7) { int ans = 1; while (b) { if (b & 1) ans = mul(ans, a, mod); a = mul(a, a, mod); b >>= 1; }return ans; }
int inverse(int a, int mod = 1e9 + 7) { return bin(a, mod - 2, mod); }
int divi(int a, int b, int mod = 1e9 + 7) {
	return mul(a, inverse(b, mod), mod);
}
ll add(ll a, ll b, ll mod = 1e9 + 7) { return (((a % mod) + (b % mod)) + mod) % mod; }
ll sub(ll a, ll b, ll mod = 1e9 + 7) { return (((a % mod) - (b % mod)) + mod) % mod; }
ll mul(ll a, ll b, ll mod = 1e9 + 7) { return (((a % mod) * (b % mod)) + mod) % mod; }
ll bin(ll a, ll b, ll mod = 1e9 + 7) { ll ans = 1; while (b) { if (b & 1) ans = mul(ans, a, mod); a = mul(a, a, mod); b >>= 1; }return ans; }
ll inverse(ll a, ll mod = 1e9 + 7) { return bin(a, mod - 2, mod); }
ll divi(ll a, ll b, ll mod = 1e9 + 7) {
	return mul(a, inverse(b, mod), mod);
}
ll ex(int base, int power)
{
	if (power == 0)
		return 1;
	ll result = ex(base, power / 2);
	if (power % 2 == 1)
		return(((result * result) % mod) * base) % mod;
	else return (result * result) % mod;
}
int gcd(int a, int b) {
	if (b == 0)return a;
	else return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
ll fac(int x) {
	ll factorial = 1;
	for (ll i = 1; i <= x; ++i) {
		factorial = mul(factorial, i);
	}
	return factorial % mod;
}
ll npr(int x, int c) {
	if (x == c) return fac(x);
	else return (fac(x) / (fac(x - c) * fac(c))) % mod;
}
void bton(string s) { stoll(s, nullptr, 2); }
inline int read() {
	int x = 0, f = 1, c = getchar();
	while (!isdigit(c)) { if (c == '-')f = -1; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	return f == 1 ? x : -x;
}
bool isPrime(int n)
{
	if (n == 2 || n == 3)
		return true;

	if (n <= 1 || n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0)
			return false;
	}

	return true;
}

/*
	first we can find a[0] and a[n-1] using the range 0,1e18+1 because a[0]>0 && a[n-1]<1e18+1
	then using that we can find a[1] by using a[0] because we know that a[1]>=a[0]+1 same for a[n-2]<=a[n-1]-1
	so can use MinMax once so that a[0] and a[n-1] is defined, then we can move into the middle so that we can recold {a[1],a[n-2]},{a[2],a[n-3]},....
	this solution will be n/2
*/
#include "gap.h"

long long findGap(int t, int n)
{
	ll l = 0, r = 0;
	vll a(n);
	MinMax(0, 1e18 + 1, &l, &r);
	a[0] = l; a[n - 1] = r;
	int lp = 1, rp = n - 2;
	while (lp <= rp) {
		MinMax(a[lp-1]+1, a[rp+1]-1, &l, &r);
		a[lp] = l; a[rp] = r;
		lp++; rp--;
	}
	ll mx = 0;
	FOR(i, 1, n) {
		mx = max(mx, a[i] - a[i - 1]);
	}
	return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 8 ms 592 KB Output is correct
17 Correct 9 ms 592 KB Output is correct
18 Correct 9 ms 720 KB Output is correct
19 Correct 9 ms 688 KB Output is correct
20 Correct 7 ms 592 KB Output is correct
21 Correct 35 ms 1868 KB Output is correct
22 Correct 41 ms 1828 KB Output is correct
23 Correct 35 ms 1816 KB Output is correct
24 Correct 37 ms 1824 KB Output is correct
25 Correct 30 ms 1816 KB Output is correct
26 Correct 35 ms 1864 KB Output is correct
27 Correct 37 ms 1868 KB Output is correct
28 Correct 43 ms 1772 KB Output is correct
29 Correct 39 ms 1752 KB Output is correct
30 Correct 30 ms 1792 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Partially correct 0 ms 208 KB Partially correct
3 Partially correct 1 ms 208 KB Partially correct
4 Partially correct 1 ms 208 KB Partially correct
5 Partially correct 1 ms 208 KB Partially correct
6 Partially correct 0 ms 208 KB Partially correct
7 Partially correct 0 ms 208 KB Partially correct
8 Partially correct 0 ms 208 KB Partially correct
9 Partially correct 0 ms 208 KB Partially correct
10 Partially correct 0 ms 208 KB Partially correct
11 Partially correct 1 ms 336 KB Partially correct
12 Partially correct 1 ms 336 KB Partially correct
13 Partially correct 1 ms 336 KB Partially correct
14 Partially correct 1 ms 336 KB Partially correct
15 Partially correct 1 ms 336 KB Partially correct
16 Partially correct 9 ms 720 KB Partially correct
17 Partially correct 9 ms 632 KB Partially correct
18 Partially correct 11 ms 592 KB Partially correct
19 Partially correct 10 ms 680 KB Partially correct
20 Partially correct 7 ms 592 KB Partially correct
21 Incorrect 41 ms 1828 KB Expected int32, but "2500100000" found
22 Incorrect 38 ms 1836 KB Expected int32, but "2500100000" found
23 Incorrect 42 ms 1840 KB Expected int32, but "2500100000" found
24 Incorrect 43 ms 1768 KB Expected int32, but "2500100000" found
25 Incorrect 30 ms 1816 KB Expected int32, but "2500100000" found
26 Incorrect 44 ms 1828 KB Expected int32, but "2500100000" found
27 Incorrect 36 ms 1852 KB Expected int32, but "2500100000" found
28 Incorrect 43 ms 1824 KB Expected int32, but "2500100000" found
29 Incorrect 34 ms 1824 KB Expected int32, but "2500100000" found
30 Incorrect 27 ms 1872 KB Expected int32, but "2500100000" found
31 Partially correct 0 ms 208 KB Partially correct
32 Partially correct 0 ms 208 KB Partially correct