Submission #954777

# Submission time Handle Problem Language Result Execution time Memory
954777 2024-03-28T14:18:01 Z Itamar Gap (APIO16_gap) C++14
70 / 100
465 ms 524288 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 = -1, b = 1e18 + 1;
		vll v;
		int num = 0;
		for (int it = 0;; it++) {
			auto *at = new ll, *bt = new ll;
			if (2+ 2 * num <= N + 1) {
				MinMax(a + 1, b - 1, at, bt);
				num++;
			}
			a = *at, b = *bt;
			v.push_back(a); v.push_back(b);
		}
		sort(v.begin(), v.end());
		ll ans = 0;
		for (int i = 0; i < v.size() - 1; 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:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i = 0; i < v.size() - 1; i++)if(v[i]>-1)ans = max(ans, v[i + 1] - v[i]);
      |                   ~~^~~~~~~~~~~~~~
gap.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int i = 0; i+1 < v.size(); i++) {
      |                   ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 445 ms 524288 KB Execution killed with signal 9
2 Runtime error 385 ms 524288 KB Execution killed with signal 9
3 Runtime error 367 ms 524288 KB Execution killed with signal 9
4 Runtime error 398 ms 524288 KB Execution killed with signal 9
5 Runtime error 372 ms 524288 KB Execution killed with signal 9
6 Runtime error 373 ms 524288 KB Execution killed with signal 9
7 Runtime error 366 ms 524288 KB Execution killed with signal 9
8 Runtime error 392 ms 524288 KB Execution killed with signal 9
9 Runtime error 372 ms 524288 KB Execution killed with signal 9
10 Runtime error 381 ms 524288 KB Execution killed with signal 9
11 Runtime error 369 ms 524288 KB Execution killed with signal 9
12 Runtime error 375 ms 524288 KB Execution killed with signal 9
13 Runtime error 376 ms 524288 KB Execution killed with signal 9
14 Runtime error 378 ms 524288 KB Execution killed with signal 9
15 Runtime error 372 ms 524288 KB Execution killed with signal 9
16 Runtime error 372 ms 524288 KB Execution killed with signal 9
17 Runtime error 390 ms 524288 KB Execution killed with signal 9
18 Runtime error 373 ms 524288 KB Execution killed with signal 9
19 Runtime error 465 ms 524288 KB Execution killed with signal 9
20 Runtime error 459 ms 524288 KB Execution killed with signal 9
21 Runtime error 449 ms 524288 KB Execution killed with signal 9
22 Runtime error 390 ms 524288 KB Execution killed with signal 9
23 Runtime error 423 ms 524288 KB Execution killed with signal 9
24 Runtime error 383 ms 524288 KB Execution killed with signal 9
25 Runtime error 391 ms 524288 KB Execution killed with signal 9
26 Runtime error 385 ms 524288 KB Execution killed with signal 9
27 Runtime error 419 ms 524288 KB Execution killed with signal 9
28 Runtime error 398 ms 524288 KB Execution killed with signal 9
29 Runtime error 390 ms 524288 KB Execution killed with signal 9
30 Runtime error 383 ms 524288 KB Execution killed with signal 9
31 Runtime error 355 ms 524288 KB Execution killed with signal 9
32 Runtime error 363 ms 524288 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 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 1 ms 2592 KB Output is correct
7 Correct 1 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 2564 KB Output is correct
12 Correct 2 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 2388 KB Output is correct
16 Correct 13 ms 4316 KB Output is correct
17 Correct 12 ms 4492 KB Output is correct
18 Correct 12 ms 4484 KB Output is correct
19 Correct 12 ms 4484 KB Output is correct
20 Correct 7 ms 4472 KB Output is correct
21 Correct 50 ms 10600 KB Output is correct
22 Correct 50 ms 10632 KB Output is correct
23 Correct 56 ms 10644 KB Output is correct
24 Correct 50 ms 10620 KB Output is correct
25 Correct 46 ms 10632 KB Output is correct
26 Correct 60 ms 10640 KB Output is correct
27 Correct 52 ms 10636 KB Output is correct
28 Correct 51 ms 10588 KB Output is correct
29 Correct 50 ms 10632 KB Output is correct
30 Correct 28 ms 9616 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct