답안 #835687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835687 2023-08-23T17:38:04 Z Khizri Gap (APIO16_gap) C++17
100 / 100
39 ms 2256 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
long long findGap(int test, int n)
{
    if(test==1){
        ll l=0,r=1e18;
        vector<ll>vt;
        while(vt.size()<n){
            ll a=0,b=0;
            MinMax(l,r,&a,&b);
            //if(b==-1) break;
            if(a!=b){
                vt.pb(a);
                vt.pb(b);
            }
            else{
                vt.pb(a);
            }
            l=a+1,r=b-1;
        }
        sort(vt.begin(),vt.end());
        ll ans=0;
        for(int i=1;i<vt.size();i++){
            ans=max(ans,vt[i]-vt[i-1]);
        }
        return ans;
    }
	ll l=0,r=0;
    MinMax(0ll,(ll)(1e18),&l,&r);
    ll res=(r-l)/(n-1);
    ll ans=(r-l)/(n-1);
    while(l<r){
        ll a=0,b=0;
        MinMax(l+1,l+res+1,&a,&b);
        if(b==-1){
            res+=res;
        }
        else{
            ans=max(ans,a-l);
            l=b;
            res=ans;
        }
    }
    return ans;
}
/*
g++ gap.cpp grader.cpp ; .\a.exe
*/

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:11:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 |         while(vt.size()<n){
      |               ~~~~~~~~~^~
gap.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i=1;i<vt.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 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 9 ms 892 KB Output is correct
17 Correct 8 ms 848 KB Output is correct
18 Correct 8 ms 804 KB Output is correct
19 Correct 9 ms 880 KB Output is correct
20 Correct 7 ms 848 KB Output is correct
21 Correct 32 ms 2200 KB Output is correct
22 Correct 39 ms 2152 KB Output is correct
23 Correct 32 ms 2212 KB Output is correct
24 Correct 37 ms 2156 KB Output is correct
25 Correct 29 ms 2256 KB Output is correct
26 Correct 31 ms 2160 KB Output is correct
27 Correct 33 ms 2248 KB Output is correct
28 Correct 32 ms 2196 KB Output is correct
29 Correct 32 ms 2196 KB Output is correct
30 Correct 27 ms 2176 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 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 5 ms 592 KB Output is correct
17 Correct 5 ms 420 KB Output is correct
18 Correct 6 ms 464 KB Output is correct
19 Correct 6 ms 464 KB Output is correct
20 Correct 2 ms 464 KB Output is correct
21 Correct 17 ms 1012 KB Output is correct
22 Correct 22 ms 1104 KB Output is correct
23 Correct 24 ms 996 KB Output is correct
24 Correct 18 ms 1008 KB Output is correct
25 Correct 37 ms 1088 KB Output is correct
26 Correct 20 ms 1192 KB Output is correct
27 Correct 19 ms 1100 KB Output is correct
28 Correct 18 ms 1064 KB Output is correct
29 Correct 24 ms 1104 KB Output is correct
30 Correct 9 ms 1100 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct