답안 #569690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
569690 2022-05-27T15:53:46 Z ali22413836 Gap (APIO16_gap) C++14
100 / 100
86 ms 8228 KB
#include "gap.h"
#include <bits/stdc++.h>
#define  endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9 + 7 ;
ll mypower(ll x, ll y){
    if(y == 0) return 1 ;
    if(y == 1) return x ;
    ll ret = mypower(x , y / 2);
    ret = (ret * ret) % mod;
    if(y % 2) ret = ( ret * x ) % mod ;
    return ret ;
}
map < ll , ll > mp ;
vector < ll > v  ;
long long findGap(int T, int N)
{
    ll n = N ;
    ll mn = -1,  mx = 1e18 ;
    if(T == 1){
        ll l = 0 , r = 1e18 + 1 ;
        while(v.size() != N){
            MinMax(l , r , &mn , &mx) ;
            if(mn == -1 && mx == -1){
                break ;
            }
            if(mp.count(mn) == 0){
                mp[mn] = 1 ;
                v.push_back(mn) ;
                l = mn + 1 ;
            }
            if(mp.count(mx) == 0){
                mp[mx] = 1 ;
                v.push_back(mx) ;
                r = mx - 1;
            }
        }
        sort(v.begin() , v.end()) ;
        ll ans = 0 ;
        for(int i = 1 ; i < N ; i++){
            ans = max(ans , v[i] - v[i - 1]) ;
        }
        return ans ;
    }
    else{
        ll l = 0 , r = 1e18 ; 
        MinMax(l , r , &l , &r) ;
        ll len = (r - l + 1) / (n - 1) ;
        ll q = l ;
        ll ans = 0 ;
        for(ll i = l + 1 ; i <= r ; i += len + 1){
            ll mn , mx ; 
            MinMax(i , i + len , &mn , &mx) ;
            if(mn != -1){
                ans = max(ans , mn - q) ;
                q = mx ;
            }
        }
        return ans ;
    }
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:26:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         while(v.size() != N){
      |               ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 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 1 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 1 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 25 ms 2160 KB Output is correct
17 Correct 18 ms 2192 KB Output is correct
18 Correct 16 ms 2252 KB Output is correct
19 Correct 18 ms 2204 KB Output is correct
20 Correct 20 ms 2252 KB Output is correct
21 Correct 80 ms 8096 KB Output is correct
22 Correct 75 ms 8088 KB Output is correct
23 Correct 76 ms 8092 KB Output is correct
24 Correct 75 ms 8084 KB Output is correct
25 Correct 73 ms 8088 KB Output is correct
26 Correct 86 ms 8228 KB Output is correct
27 Correct 75 ms 8052 KB Output is correct
28 Correct 79 ms 8044 KB Output is correct
29 Correct 74 ms 8048 KB Output is correct
30 Correct 75 ms 8136 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 1 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 1 ms 252 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 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 12 ms 508 KB Output is correct
17 Correct 13 ms 508 KB Output is correct
18 Correct 14 ms 464 KB Output is correct
19 Correct 13 ms 464 KB Output is correct
20 Correct 8 ms 464 KB Output is correct
21 Correct 50 ms 1076 KB Output is correct
22 Correct 63 ms 968 KB Output is correct
23 Correct 55 ms 1160 KB Output is correct
24 Correct 49 ms 980 KB Output is correct
25 Correct 46 ms 1076 KB Output is correct
26 Correct 55 ms 1092 KB Output is correct
27 Correct 55 ms 1048 KB Output is correct
28 Correct 53 ms 964 KB Output is correct
29 Correct 51 ms 1104 KB Output is correct
30 Correct 26 ms 1088 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct