답안 #367744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367744 2021-02-18T08:39:50 Z abra_stone Gap (APIO16_gap) C++14
100 / 100
84 ms 3424 KB
#include "gap.h"
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
ll ans;
vector<ll> a;

ll findGap(int T, int n) {
    ll i, mn = 0, mx = 2e18;
    if (T == 1) {
        for (i = 0; i < n; i += 2) {
            MinMax(mn, mx, &mn, &mx);
            a.push_back(mn);
            a.push_back(mx);
            mn++;
            mx--;
        }
    } else {
        ll tmn, tmx;
        MinMax(mn, mx, &mn, &mx);
        a.push_back(mn);
        a.push_back(mx);
        ll t = (mx - mn + n - 2) / (n - 1);
        mn++;
        mx--;
        for (i = mn; i <= mx; i += t + 1) {
            MinMax(i, i + t, &tmn, &tmx);
            a.push_back(tmn);
            a.push_back(tmx);
        }
    }
    sort(a.begin(), a.end());
    for (i = 1; i < a.size(); i++) {
        ans = max(ans, a[i] - a[i - 1]);
    }
	return ans;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:35:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (i = 1; i < a.size(); i++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 12 ms 1004 KB Output is correct
17 Correct 12 ms 876 KB Output is correct
18 Correct 12 ms 876 KB Output is correct
19 Correct 14 ms 896 KB Output is correct
20 Correct 12 ms 888 KB Output is correct
21 Correct 49 ms 2276 KB Output is correct
22 Correct 56 ms 2276 KB Output is correct
23 Correct 49 ms 2276 KB Output is correct
24 Correct 49 ms 2276 KB Output is correct
25 Correct 44 ms 2276 KB Output is correct
26 Correct 50 ms 2276 KB Output is correct
27 Correct 52 ms 2276 KB Output is correct
28 Correct 55 ms 2276 KB Output is correct
29 Correct 55 ms 2276 KB Output is correct
30 Correct 51 ms 2276 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 17 ms 1128 KB Output is correct
17 Correct 17 ms 1128 KB Output is correct
18 Correct 17 ms 1128 KB Output is correct
19 Correct 16 ms 1152 KB Output is correct
20 Correct 10 ms 1128 KB Output is correct
21 Correct 71 ms 3240 KB Output is correct
22 Correct 70 ms 3292 KB Output is correct
23 Correct 84 ms 3296 KB Output is correct
24 Correct 70 ms 3296 KB Output is correct
25 Correct 62 ms 3316 KB Output is correct
26 Correct 73 ms 3424 KB Output is correct
27 Correct 72 ms 3296 KB Output is correct
28 Correct 79 ms 3296 KB Output is correct
29 Correct 70 ms 3252 KB Output is correct
30 Correct 42 ms 3296 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct