답안 #43637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43637 2018-03-18T21:37:44 Z spencercompton Gap (APIO16_gap) C++14
70 / 100
94 ms 3556 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
// vector<long long> li;
// void MinMax(long long a, long long b, long long *c, long long *d){
//     vector<long long> ar;
//     for(int i = 0; i<li.size(); i++){
//         if(li[i]>=a && li[i]<=b){
//             ar.push_back(li[i]);
//         }
//     }
//     if(ar.size()==0){
//         *c = -1;
//         *d = -1;
//     }
//     else{
//         *c = ar[0];
//         *d = ar[ar.size()-1];
//     }
// }
long long findGap(int T, int N)
{
    long long maxval = 1000000000000000000LL;
    long long mn, mx;
    MinMax(1,maxval,&mn,&mx);
    long long s = mn;
    long long e = mx;
    if(N==1){
        return e-s;
    }
    long long ans = (e-s)/((long long)N-1LL)-1LL;
    if((e-s)%((long long)N-1LL)!=0){
        ans++;
    }
    long long last = s;
    long long check = ans+1LL;
    vector<long long> all;
    all.push_back(s);
    for(long long i = s+1LL; i<e; i+=check){
        long long r = min(e-1LL,i+check-1LL);
        MinMax(i,r,&mn,&mx);
        if(mn!=-1){
            all.push_back(mn);
            all.push_back(mx);
        }
    }
    all.push_back(e);
    for(int i = 1; i<all.size(); i++){
        ans = max(ans,all[i]-all[i-1]);
    }
    return ans;
}
// int main(){
//     li.push_back(2);
//     li.push_back(3);
//     li.push_back(6);
//     li.push_back(8);
//     cout << findGap(0,4) << endl;
// }

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:48:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i<all.size(); i++){
                     ^
gap.cpp:35:15: warning: unused variable 'last' [-Wunused-variable]
     long long last = s;
               ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 376 KB Output isn't correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Incorrect 1 ms 428 KB Output isn't correct
4 Incorrect 1 ms 448 KB Output isn't correct
5 Incorrect 1 ms 448 KB Output isn't correct
6 Incorrect 1 ms 448 KB Output isn't correct
7 Incorrect 1 ms 448 KB Output isn't correct
8 Incorrect 2 ms 616 KB Output isn't correct
9 Incorrect 1 ms 616 KB Output isn't correct
10 Incorrect 2 ms 616 KB Output isn't correct
11 Incorrect 2 ms 616 KB Output isn't correct
12 Incorrect 2 ms 616 KB Output isn't correct
13 Incorrect 2 ms 616 KB Output isn't correct
14 Incorrect 2 ms 616 KB Output isn't correct
15 Incorrect 2 ms 616 KB Output isn't correct
16 Incorrect 19 ms 1116 KB Output isn't correct
17 Incorrect 19 ms 1116 KB Output isn't correct
18 Incorrect 19 ms 1116 KB Output isn't correct
19 Incorrect 19 ms 1116 KB Output isn't correct
20 Incorrect 10 ms 1116 KB Output isn't correct
21 Incorrect 73 ms 2512 KB Output isn't correct
22 Incorrect 74 ms 2512 KB Output isn't correct
23 Incorrect 72 ms 2516 KB Output isn't correct
24 Incorrect 74 ms 2516 KB Output isn't correct
25 Incorrect 74 ms 3532 KB Output isn't correct
26 Incorrect 73 ms 3532 KB Output isn't correct
27 Incorrect 75 ms 3532 KB Output isn't correct
28 Incorrect 94 ms 3532 KB Output isn't correct
29 Incorrect 79 ms 3532 KB Output isn't correct
30 Incorrect 43 ms 3532 KB Output isn't correct
31 Incorrect 2 ms 3532 KB Output isn't correct
32 Incorrect 2 ms 3532 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3532 KB Output is correct
2 Correct 1 ms 3532 KB Output is correct
3 Correct 1 ms 3532 KB Output is correct
4 Correct 2 ms 3532 KB Output is correct
5 Correct 1 ms 3532 KB Output is correct
6 Correct 2 ms 3532 KB Output is correct
7 Correct 2 ms 3532 KB Output is correct
8 Correct 2 ms 3532 KB Output is correct
9 Correct 2 ms 3532 KB Output is correct
10 Correct 2 ms 3532 KB Output is correct
11 Correct 2 ms 3532 KB Output is correct
12 Correct 3 ms 3532 KB Output is correct
13 Correct 2 ms 3532 KB Output is correct
14 Correct 2 ms 3532 KB Output is correct
15 Correct 2 ms 3532 KB Output is correct
16 Correct 28 ms 3532 KB Output is correct
17 Correct 20 ms 3532 KB Output is correct
18 Correct 20 ms 3532 KB Output is correct
19 Correct 21 ms 3532 KB Output is correct
20 Correct 9 ms 3532 KB Output is correct
21 Correct 75 ms 3532 KB Output is correct
22 Correct 77 ms 3532 KB Output is correct
23 Correct 74 ms 3532 KB Output is correct
24 Correct 72 ms 3532 KB Output is correct
25 Correct 69 ms 3556 KB Output is correct
26 Correct 74 ms 3556 KB Output is correct
27 Correct 75 ms 3556 KB Output is correct
28 Correct 94 ms 3556 KB Output is correct
29 Correct 76 ms 3556 KB Output is correct
30 Correct 42 ms 3556 KB Output is correct
31 Correct 1 ms 3556 KB Output is correct
32 Correct 2 ms 3556 KB Output is correct