답안 #95555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95555 2019-02-02T04:01:48 Z hihi Gap (APIO16_gap) C++11
100 / 100
66 ms 4212 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;

long long findGap(int T, int N)
{
    long long min, maxi;
    if (T == 1) {
        vector<long long> a;
        MinMax(0, (long long)1012345678901234567, &min, &maxi);
        for (int i = 0; i < (N-1)/2; i++) {
            a.push_back(min);
            a.push_back(maxi);
            long long temp = min+1;
            long long temp2 = maxi-1;
            MinMax(temp, temp2, &min, &maxi);
        }
        if (N%2==0) {
            a.push_back(min);
            a.push_back(maxi);
        }
        else {
            a.push_back(min);
        }
        sort(a.begin(), a.end());
        long long gap = 0;
        for (int i = 1; i < a.size(); i++) {
            gap = max(a[i] - a[i-1], gap);
        }
        return gap;
    }
	else {
	    MinMax(0, (long long)1012345678901234567, &min, &maxi);
	    long long gap = 0;
	    vector<long long> a;
	    long long dis = ceil((maxi - min )/((long double)N-1) + 1);
	    long long min2 = min, max2 = (min + dis);
	    for (int i = 0; i < N-1; i++) {
	        MinMax(min2, max2, &min, &maxi);
	        if (min == maxi && min != -1) {
	            a.push_back(min);
	        }
	        else if (min != maxi) {
	            a.push_back(min);
	            a.push_back(maxi);
	        }
	        min2 = max2+1;
	        max2 += dis;
	    }
	    for (int i = 1; i < a.size(); i++) {
            gap = max(a[i] - a[i-1], gap);
        }
        return gap;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < a.size(); i++) {
                         ~~^~~~~~~~~~
gap.cpp:50:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for (int i = 1; i < a.size(); i++) {
                      ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 360 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 372 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 380 KB Output is correct
16 Correct 15 ms 1400 KB Output is correct
17 Correct 14 ms 1400 KB Output is correct
18 Correct 15 ms 1400 KB Output is correct
19 Correct 15 ms 1400 KB Output is correct
20 Correct 11 ms 1016 KB Output is correct
21 Correct 53 ms 4204 KB Output is correct
22 Correct 52 ms 4208 KB Output is correct
23 Correct 52 ms 4080 KB Output is correct
24 Correct 54 ms 4208 KB Output is correct
25 Correct 44 ms 3440 KB Output is correct
26 Correct 52 ms 4208 KB Output is correct
27 Correct 52 ms 4212 KB Output is correct
28 Correct 51 ms 4208 KB Output is correct
29 Correct 53 ms 4208 KB Output is correct
30 Correct 44 ms 3056 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 424 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 16 ms 1404 KB Output is correct
17 Correct 17 ms 1448 KB Output is correct
18 Correct 16 ms 1400 KB Output is correct
19 Correct 16 ms 1332 KB Output is correct
20 Correct 8 ms 760 KB Output is correct
21 Correct 62 ms 4180 KB Output is correct
22 Correct 66 ms 4208 KB Output is correct
23 Correct 63 ms 4204 KB Output is correct
24 Correct 64 ms 4080 KB Output is correct
25 Correct 59 ms 3612 KB Output is correct
26 Correct 65 ms 4176 KB Output is correct
27 Correct 64 ms 4208 KB Output is correct
28 Correct 64 ms 4080 KB Output is correct
29 Correct 64 ms 4104 KB Output is correct
30 Correct 33 ms 2296 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct