답안 #835685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835685 2023-08-23T17:36:58 Z aykhn Gap (APIO16_gap) C++14
100 / 100
42 ms 2248 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define pb push_back
#define all(v) v.begin(), v.end()

ll findGap(int ajfghkdshgfghadsfghkadshgfagsdkfhadkshfgkhadsfadskjadsghfkhjasdgfkj, int n)
{
    if (ajfghkdshgfghadsfghkadshgfagsdkfhadkshfgkhadsfadskjadsghfkhjasdgfkj == 2)
    {
        ll f = 0, l = 0;
        MinMax(0 * 1LL, 1LL * 1e18, &f, &l);
        ll last = l;
        ll add = (l - f)/(n - 1);
        ll res = add;

        while (f < last)
        {
            ll lx, rx;
            lx = 'n' + 'i' + 'g' + 'g' + 'a';
            rx = 'n' + 'i' + 'g' + 'g' + 'a';
            MinMax(f + 1, f + add, &lx, &rx);
            if (lx == -1) add <<= 1;
            else
            {
                res = max(res, lx - f);
                add = res;
                f = rx;
            }
        }
        return res;
    }
    else if (ajfghkdshgfghadsfghkadshgfagsdkfhadkshfgkhadsfadskjadsghfkhjasdgfkj == 1)
    {
        vector<ll> v;
        ll l = 0, r = 1e18;
        while (l <= r && v.size() < n)
        {
            ll lx, rx;
            MinMax(l, r, &lx, &rx);
            if (lx == -1) break;
            v.pb(lx);
            if (lx != rx) v.pb(rx);
            l = lx + 1;
            r = rx - 1;
        }
        sort(all(v));
        ll res = 0;
        for (int i = 1; i < v.size(); i++)
        {
            res = max(res, v[i] - v[i - 1]);
        }
        return res;
    }


}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:40:35: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |         while (l <= r && v.size() < n)
      |                          ~~~~~~~~~^~~
gap.cpp:52:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for (int i = 1; i < v.size(); i++)
      |                         ~~^~~~~~~~~~
gap.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
# 결과 실행 시간 메모리 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 1 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 336 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 8 ms 796 KB Output is correct
17 Correct 8 ms 848 KB Output is correct
18 Correct 9 ms 848 KB Output is correct
19 Correct 8 ms 848 KB Output is correct
20 Correct 7 ms 848 KB Output is correct
21 Correct 32 ms 2148 KB Output is correct
22 Correct 32 ms 2248 KB Output is correct
23 Correct 37 ms 2236 KB Output is correct
24 Correct 35 ms 2180 KB Output is correct
25 Correct 36 ms 2172 KB Output is correct
26 Correct 39 ms 2196 KB Output is correct
27 Correct 32 ms 2240 KB Output is correct
28 Correct 32 ms 2200 KB Output is correct
29 Correct 34 ms 2208 KB Output is correct
30 Correct 27 ms 2248 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 7 ms 464 KB Output is correct
17 Correct 5 ms 464 KB Output is correct
18 Correct 4 ms 516 KB Output is correct
19 Correct 7 ms 484 KB Output is correct
20 Correct 2 ms 464 KB Output is correct
21 Correct 17 ms 1104 KB Output is correct
22 Correct 18 ms 1044 KB Output is correct
23 Correct 18 ms 1124 KB Output is correct
24 Correct 18 ms 1104 KB Output is correct
25 Correct 42 ms 1088 KB Output is correct
26 Correct 21 ms 976 KB Output is correct
27 Correct 28 ms 1104 KB Output is correct
28 Correct 25 ms 976 KB Output is correct
29 Correct 19 ms 1044 KB Output is correct
30 Correct 16 ms 1052 KB Output is correct
31 Correct 1 ms 260 KB Output is correct
32 Correct 1 ms 208 KB Output is correct