답안 #954786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954786 2024-03-28T14:27:33 Z Itamar Gap (APIO16_gap) C++14
100 / 100
56 ms 10696 KB
#include "gap.h"
using namespace std;
#define ll long long
#include <vector>
#define vll vector<ll>
#include <algorithm>
long long findGap(int T, int N)
{
	if (T == 1) {
		ll a = 0, b = 1e18;
		vll v;
		int num = 0;
		for (int it = 0; it < (N + 1)/2 ; it++) {
			auto *at = new ll, *bt = new ll;
			MinMax(a, b , at, bt);
			a = *at, b = *bt;
			v.push_back(a); v.push_back(b);
			a++, b--;
		}
		sort(v.begin(), v.end());
		ll ans = v[1]-v[0];
		for (int i = 0; i+1 < v.size(); i++)if(v[i]>-1)ans = max(ans, v[i + 1] - v[i]);
		return ans;
	}
	else {
		auto* a = new ll, * b = new  ll;
		MinMax(0, 1e18, a, b);
		vll v;
		ll d = ((* b) - (* a) + N - 2) / (N - 1);
		for (ll i = *a; i < *b; i += d + 1) {
			auto *c = new ll, * k = new ll;
			MinMax(i, i+d, c, k);
			v.push_back((ll)*c); v.push_back((ll) * k);
		}
		sort(v.begin(), v.end());
		ll ans = d;
		for (int i = 0; i+1 < v.size(); i++) {
			if (v[i] > -1) {
				ans = max(ans, v[i + 1] - v[i]);
			}
		}
		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int i = 0; i+1 < v.size(); i++)if(v[i]>-1)ans = max(ans, v[i + 1] - v[i]);
      |                   ~~~~^~~~~~~~~~
gap.cpp:12:7: warning: unused variable 'num' [-Wunused-variable]
   12 |   int num = 0;
      |       ^~~
gap.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int i = 0; i+1 < v.size(); i++) {
      |                   ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 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 1 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 9 ms 3460 KB Output is correct
17 Correct 9 ms 3452 KB Output is correct
18 Correct 9 ms 3444 KB Output is correct
19 Correct 8 ms 3464 KB Output is correct
20 Correct 7 ms 3432 KB Output is correct
21 Correct 34 ms 6544 KB Output is correct
22 Correct 35 ms 6804 KB Output is correct
23 Correct 33 ms 6548 KB Output is correct
24 Correct 34 ms 6552 KB Output is correct
25 Correct 30 ms 6656 KB Output is correct
26 Correct 36 ms 6564 KB Output is correct
27 Correct 34 ms 6552 KB Output is correct
28 Correct 33 ms 6552 KB Output is correct
29 Correct 35 ms 6776 KB Output is correct
30 Correct 28 ms 6540 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 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 1 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 12 ms 4556 KB Output is correct
17 Correct 13 ms 4468 KB Output is correct
18 Correct 12 ms 4488 KB Output is correct
19 Correct 12 ms 4480 KB Output is correct
20 Correct 7 ms 4464 KB Output is correct
21 Correct 51 ms 10528 KB Output is correct
22 Correct 50 ms 10624 KB Output is correct
23 Correct 51 ms 10648 KB Output is correct
24 Correct 51 ms 10580 KB Output is correct
25 Correct 45 ms 10684 KB Output is correct
26 Correct 51 ms 10628 KB Output is correct
27 Correct 51 ms 10696 KB Output is correct
28 Correct 51 ms 10592 KB Output is correct
29 Correct 56 ms 10644 KB Output is correct
30 Correct 28 ms 9808 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct