답안 #656722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
656722 2022-11-08T05:52:58 Z Ronin13 Gap (APIO16_gap) C++14
100 / 100
60 ms 2640 KB
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;



long long findGap(int T, int N){

    ll n = N;
    if(T == 1){
        ll l = 0, r = 1e18;
        ll mn, mx;
        vector <ll> a, b;
        int cnt = 0;
        while(l < r){
            if(cnt >= (n + 1) / 2) break;
            cnt++;
            MinMax(l, r, &mn, &mx);

            if(mn == -1 || mx == -1) break;
            if(mn != -1)a.pb(mn);
            if(mx != -1)b.pb(mx);
            l = mn + 1;
            r = mx - 1;
        }

        reverse(b.begin(), b.end());
        for(ll to : b) a.pb(to);
        ll ans = 0;
        for(int i = 1; i < a.size(); i++) ans = max(ans, a[i] - a[i - 1]);
        return ans;
    }
    ll l, r;
    l = 0, r = 1e18;
    vector <ll> vec;
    ll mn, mx;
    MinMax(l, r, &mn, &mx);
    vec.pb(mn);
    ll v = mn;
    ll d = mx - mn;
    d = (d + (n - 2) )/ (n - 1);
    l = mn;
    ll D = mx;
    for(int i = 1; i <= n; i++){
        ll L = l + d;

        MinMax(l + 1, l + d, &mn, &mx);
        l = max(L, mx + 1);
        if(mn != -1) vec.pb(mn);
        if(mn != mx)
        if(mx != -1) vec.pb(mx);
    }
   // for(ll to : vec) cout << to << ' ';
    ll ans = 0;
    for(int i = 1; i < vec.size(); i++) ans = max(ans, vec[i] - vec[i - 1]);
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int i = 1; i < a.size(); i++) ans = max(ans, a[i] - a[i - 1]);
      |                        ~~^~~~~~~~~~
gap.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i = 1; i < vec.size(); i++) ans = max(ans, vec[i] - vec[i - 1]);
      |                    ~~^~~~~~~~~~~~
gap.cpp:47:8: warning: unused variable 'v' [-Wunused-variable]
   47 |     ll v = mn;
      |        ^
gap.cpp:51:8: warning: unused variable 'D' [-Wunused-variable]
   51 |     ll D = mx;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 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 2 ms 336 KB Output is correct
16 Correct 12 ms 948 KB Output is correct
17 Correct 12 ms 936 KB Output is correct
18 Correct 10 ms 936 KB Output is correct
19 Correct 12 ms 972 KB Output is correct
20 Correct 7 ms 976 KB Output is correct
21 Correct 37 ms 2576 KB Output is correct
22 Correct 36 ms 2540 KB Output is correct
23 Correct 47 ms 2624 KB Output is correct
24 Correct 36 ms 2540 KB Output is correct
25 Correct 31 ms 2540 KB Output is correct
26 Correct 37 ms 2548 KB Output is correct
27 Correct 37 ms 2540 KB Output is correct
28 Correct 37 ms 2640 KB Output is correct
29 Correct 42 ms 2524 KB Output is correct
30 Correct 32 ms 2540 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 1 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 1 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 13 ms 860 KB Output is correct
17 Correct 12 ms 896 KB Output is correct
18 Correct 15 ms 812 KB Output is correct
19 Correct 12 ms 812 KB Output is correct
20 Correct 6 ms 540 KB Output is correct
21 Correct 49 ms 2204 KB Output is correct
22 Correct 49 ms 2208 KB Output is correct
23 Correct 53 ms 2204 KB Output is correct
24 Correct 58 ms 2144 KB Output is correct
25 Correct 45 ms 2180 KB Output is correct
26 Correct 50 ms 2208 KB Output is correct
27 Correct 50 ms 2204 KB Output is correct
28 Correct 50 ms 2236 KB Output is correct
29 Correct 60 ms 2160 KB Output is correct
30 Correct 26 ms 1436 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct