답안 #261683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261683 2020-08-12T00:39:02 Z ant101 Gap (APIO16_gap) C++14
30 / 100
91 ms 3492 KB
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include "gap.h"
using namespace std;
 
#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
 
#undef int
long long findGap(int T, int N)
{
#define int long long
	if(T == 1){
		vector<int> all;
		int curl = 1;
		int curr = 1e18;
		int dd = 0;
		while(curl <= curr and dd < N){
			int whAt1 = 0;
			int whAt2 = 0;
			MinMax(curl,curr,&whAt1,&whAt2);
			all.pb(whAt1);
			if(whAt1 != whAt2)all.pb(whAt2);
			dd += 1+(whAt1 != whAt2);
			curl = whAt1+1;
			curr = whAt2-1;
		}
		sort(all(all));
		int ans = 0;
		REP(i,N-1){
			ans = max(ans,all[i+1]-all[i]);
		}
		return ans;
	}
	else{
		int st,en;
		int n= N;
		MinMax((int)1,(int)1e18,&st,&en);
        if(n == 2)return en-st;
		int rangesize = (en-st-1+n-2)/(n-1);
		int frm = st+1;
		vector<int> all;
		all.pb(st);
		all.pb(en);
		REP(i,n){
			int oo1,oo2;
			if(frm >= en)break;
			MinMax(frm,min(frm+rangesize-1,en-1),&oo1,&oo2);
			all.pb(oo2);
			all.pb(oo1);
			frm += rangesize;
		}
		int ans = 0;
		sort(all(all));
		REP(i,(int)all.size()-1){
			ans = max(ans,all[i+1]-all[i]);
		}
		return ans;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 20 ms 896 KB Output is correct
17 Correct 15 ms 1000 KB Output is correct
18 Correct 17 ms 896 KB Output is correct
19 Correct 16 ms 896 KB Output is correct
20 Correct 12 ms 896 KB Output is correct
21 Correct 57 ms 2288 KB Output is correct
22 Correct 61 ms 2288 KB Output is correct
23 Correct 59 ms 2288 KB Output is correct
24 Correct 57 ms 2288 KB Output is correct
25 Correct 49 ms 2288 KB Output is correct
26 Correct 57 ms 2288 KB Output is correct
27 Correct 59 ms 2288 KB Output is correct
28 Correct 77 ms 2288 KB Output is correct
29 Correct 57 ms 2336 KB Output is correct
30 Correct 44 ms 2276 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Incorrect 1 ms 384 KB Output isn't correct
16 Correct 21 ms 1148 KB Output is correct
17 Correct 19 ms 1148 KB Output is correct
18 Correct 18 ms 1148 KB Output is correct
19 Correct 19 ms 1148 KB Output is correct
20 Correct 10 ms 1148 KB Output is correct
21 Correct 88 ms 3312 KB Output is correct
22 Correct 91 ms 3308 KB Output is correct
23 Correct 83 ms 3308 KB Output is correct
24 Correct 90 ms 3308 KB Output is correct
25 Incorrect 67 ms 3308 KB Output isn't correct
26 Correct 89 ms 3492 KB Output is correct
27 Correct 81 ms 3308 KB Output is correct
28 Correct 90 ms 3288 KB Output is correct
29 Correct 81 ms 3308 KB Output is correct
30 Correct 49 ms 3308 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct