답안 #556435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556435 2022-05-03T06:51:59 Z InternetPerson10 Gap (APIO16_gap) C++17
100 / 100
58 ms 3236 KB
#include "gap.h"
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

long long findGap(int T, int N) {
    if(T == 1) {
        vector<ll> nums(N);
        ll a, b, x, y, i = 0;
        a = 0, b = (long long)1000000000000000000LL;
        while(i * 2 < N) {
            MinMax(a, b, &x, &y);
            nums[i] = x;
            nums[N - i - 1] = y;
            i++; a = x + 1; b = y - 1;
        }
        ll ans = 0;
        for(int i = 1; i < N; i++) {
            ans = max(ans, nums[i] - nums[i-1]);
        }
        return ans;
    }
    if(T == 2) {
        ll l, r;
        MinMax(0, (ll)1e18, &l, &r);
        ll siz = (r - l);
        ll x = siz / N, y = (siz + N - 1) / N, a, b;
        ll i = N;
        while(x * i + y * (N - i) != siz) {
            i--;
            if(i == -1) {
                while(true) {}
            }
        }
        ll j = N - i;
        ll ans = y;
        ll g = l;
        vector<ll> nums;
        nums.push_back(l);
        while(i--) {
            if(x == 0) continue;
            MinMax(g + 1, g + x, &a, &b);
            g += x;
            if(a == -1) continue;
            nums.push_back(a);
            nums.push_back(b);
        }
        while(j--) {
            if(y == 0) continue;
            MinMax(g + 1, g + y, &a, &b);
            g += y;
            if(a == -1) continue;
            nums.push_back(a);
            nums.push_back(b);
        }
        for(int i = 1; i < nums.size(); i++) {
            ans = max(ans, nums[i] - nums[i-1]);
        }
        return ans;
    }
	return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int i = 1; i < nums.size(); i++) {
      |                        ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 672 KB Output is correct
17 Correct 9 ms 720 KB Output is correct
18 Correct 9 ms 592 KB Output is correct
19 Correct 9 ms 716 KB Output is correct
20 Correct 8 ms 720 KB Output is correct
21 Correct 39 ms 1788 KB Output is correct
22 Correct 35 ms 1828 KB Output is correct
23 Correct 36 ms 1752 KB Output is correct
24 Correct 38 ms 1824 KB Output is correct
25 Correct 36 ms 1824 KB Output is correct
26 Correct 34 ms 1812 KB Output is correct
27 Correct 35 ms 1832 KB Output is correct
28 Correct 36 ms 1840 KB Output is correct
29 Correct 35 ms 1828 KB Output is correct
30 Correct 29 ms 1840 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 236 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 292 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 14 ms 848 KB Output is correct
17 Correct 12 ms 932 KB Output is correct
18 Correct 14 ms 896 KB Output is correct
19 Correct 13 ms 876 KB Output is correct
20 Correct 8 ms 520 KB Output is correct
21 Correct 53 ms 2240 KB Output is correct
22 Correct 52 ms 2204 KB Output is correct
23 Correct 55 ms 2260 KB Output is correct
24 Correct 50 ms 2136 KB Output is correct
25 Correct 48 ms 3236 KB Output is correct
26 Correct 52 ms 2204 KB Output is correct
27 Correct 58 ms 2368 KB Output is correct
28 Correct 52 ms 2212 KB Output is correct
29 Correct 57 ms 2240 KB Output is correct
30 Correct 27 ms 1536 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct