답안 #1073421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073421 2024-08-24T14:26:44 Z Hugo1729 Gap (APIO16_gap) C++17
30 / 100
2000 ms 4380 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll solve1(int T, int N){
	ll s=0,t=1e18,ml=0,mr;

	vector<ll> ans,sus2;
	
	for(int i=0;i<N;i+=2){
		MinMax(s,t,&ml,&mr);

		if(mr==-1)break;

		ans.push_back(ml);
		if(ml==mr)break;
		sus2.push_back(mr);

		s=ml+1;
		t=mr-1;
	}

	for(int j=sus2.size()-1;j>=0;j--){
		ans.push_back(sus2[j]);
	}

	ll out=0;

	for(int i=0;i<N;i++){
		out=max(out,ans[i+1]-ans[i]);
	}

	// for(int i : ans)cout << i << ' ';
	// cout << '\n';
	

	return out;
}

ll solve2(int T, int N){
	ll s=0,t=1e18,ml=0,mr;
	
	MinMax(s,t,&ml,&mr);

	ll lo=ml,hi=mr;
	ll L=hi-lo;
	ll sus=(L+N-2)/(N-1);

	ll ans = sus;

	ll prev=lo;

	for(int i=ml+1;i<hi;i+=sus){
		MinMax(i,min(i+sus,hi-1),&ml,&mr);
		if(ml==-1)continue;

		ans=max(ans,ml-prev);

		prev=mr;
	}

	return max(ans,hi-prev);
}

ll findGap(int T, int N){
	if(T==1)return solve1(T,N);
	else return solve2(T,N);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 7 ms 2904 KB Output is correct
17 Correct 7 ms 3064 KB Output is correct
18 Correct 7 ms 2904 KB Output is correct
19 Correct 7 ms 3060 KB Output is correct
20 Correct 5 ms 2904 KB Output is correct
21 Correct 35 ms 4224 KB Output is correct
22 Correct 27 ms 4228 KB Output is correct
23 Correct 26 ms 4212 KB Output is correct
24 Correct 26 ms 4268 KB Output is correct
25 Correct 24 ms 4256 KB Output is correct
26 Correct 26 ms 4212 KB Output is correct
27 Correct 28 ms 4380 KB Output is correct
28 Correct 26 ms 4212 KB Output is correct
29 Correct 27 ms 4220 KB Output is correct
30 Correct 26 ms 4212 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3072 ms 2392 KB Time limit exceeded
2 Execution timed out 3036 ms 2392 KB Time limit exceeded
3 Execution timed out 3077 ms 2392 KB Time limit exceeded
4 Execution timed out 3048 ms 2392 KB Time limit exceeded
5 Correct 1 ms 2392 KB Output is correct
6 Execution timed out 3095 ms 2392 KB Time limit exceeded
7 Execution timed out 3071 ms 2392 KB Time limit exceeded
8 Execution timed out 3033 ms 2392 KB Time limit exceeded
9 Execution timed out 3071 ms 2392 KB Time limit exceeded
10 Correct 1 ms 2392 KB Output is correct
11 Execution timed out 3014 ms 2392 KB Time limit exceeded
12 Execution timed out 3049 ms 2392 KB Time limit exceeded
13 Execution timed out 3058 ms 2392 KB Time limit exceeded
14 Execution timed out 3061 ms 2392 KB Time limit exceeded
15 Execution timed out 3048 ms 2392 KB Time limit exceeded
16 Execution timed out 3047 ms 2392 KB Time limit exceeded
17 Execution timed out 3030 ms 2392 KB Time limit exceeded
18 Execution timed out 3065 ms 2392 KB Time limit exceeded
19 Execution timed out 3003 ms 2392 KB Time limit exceeded
20 Partially correct 5 ms 2392 KB Partially correct
21 Execution timed out 3074 ms 2732 KB Time limit exceeded
22 Execution timed out 3062 ms 2648 KB Time limit exceeded
23 Execution timed out 3049 ms 2648 KB Time limit exceeded
24 Execution timed out 3045 ms 2648 KB Time limit exceeded
25 Execution timed out 3071 ms 2648 KB Time limit exceeded
26 Execution timed out 3063 ms 2648 KB Time limit exceeded
27 Execution timed out 3049 ms 2648 KB Time limit exceeded
28 Execution timed out 3004 ms 2648 KB Time limit exceeded
29 Execution timed out 3041 ms 2648 KB Time limit exceeded
30 Partially correct 22 ms 2648 KB Partially correct
31 Execution timed out 3060 ms 2392 KB Time limit exceeded
32 Execution timed out 3055 ms 2392 KB Time limit exceeded