답안 #95683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95683 2019-02-02T07:39:39 Z errorgorn Gap (APIO16_gap) C++14
100 / 100
69 ms 2444 KB
#include "gap.h"
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

long long findGap(int T, int N){
    if (T==1){
        long long arr[N];
int s=0,e=N-1;
long long a=0,b=1000000000000000000,sm,lm;
while (e-s>0){
    MinMax(a,b,&sm,&lm);
    arr[s]=sm,arr[e]=lm;
    a=sm+1,b=lm-1;
    s++,e--;
}
if (e==s){
    MinMax(a,b,&sm,&lm);
    arr[e]=sm;
}
long long maximal=0;
for (int x=1;x<N;x++){
    maximal=max(maximal,arr[x]-arr[x-1]);
}
return maximal;
    }
    else{
    vector<long long> v;
long long small,big;
MinMax(0,1000000000000000000,&small,&big);
long long gap=(big-small)/((long long) N-1);
long long si=small,se=small+(gap++);
long long mn,mx;
while (si<=big){
    MinMax(si,se,&mn,&mx);
    if(mn!=-1){
    v.push_back(mn);
    if (mx!=mn) v.push_back(mx);
    }
    si+=gap,se+=gap;
}
long long maximal=0;
for (int it=1;it<v.size();it++){
    maximal=max(maximal,v[it]-v[it-1]);
}
return maximal;
    }
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:44:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for (int it=1;it<v.size();it++){
               ~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 13 ms 632 KB Output is correct
17 Correct 13 ms 680 KB Output is correct
18 Correct 13 ms 632 KB Output is correct
19 Correct 12 ms 632 KB Output is correct
20 Correct 9 ms 632 KB Output is correct
21 Correct 47 ms 1912 KB Output is correct
22 Correct 46 ms 1912 KB Output is correct
23 Correct 47 ms 1956 KB Output is correct
24 Correct 47 ms 1912 KB Output is correct
25 Correct 41 ms 1912 KB Output is correct
26 Correct 47 ms 1912 KB Output is correct
27 Correct 47 ms 1916 KB Output is correct
28 Correct 49 ms 1912 KB Output is correct
29 Correct 47 ms 1876 KB Output is correct
30 Correct 35 ms 1912 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 396 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 17 ms 888 KB Output is correct
17 Correct 40 ms 888 KB Output is correct
18 Correct 17 ms 892 KB Output is correct
19 Correct 18 ms 888 KB Output is correct
20 Correct 8 ms 508 KB Output is correct
21 Correct 65 ms 2340 KB Output is correct
22 Correct 67 ms 2296 KB Output is correct
23 Correct 65 ms 2348 KB Output is correct
24 Correct 65 ms 2228 KB Output is correct
25 Correct 61 ms 2288 KB Output is correct
26 Correct 69 ms 2444 KB Output is correct
27 Correct 66 ms 2288 KB Output is correct
28 Correct 65 ms 2296 KB Output is correct
29 Correct 66 ms 2288 KB Output is correct
30 Correct 32 ms 1528 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct