답안 #43636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43636 2018-03-18T21:37:11 Z spencercompton Gap (APIO16_gap) C++14
70 / 100
105 ms 3660 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-1LL;
    }
    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 248 KB Output isn't correct
2 Incorrect 2 ms 352 KB Output isn't correct
3 Incorrect 1 ms 424 KB Output isn't correct
4 Incorrect 1 ms 544 KB Output isn't correct
5 Incorrect 1 ms 544 KB Output isn't correct
6 Incorrect 1 ms 544 KB Output isn't correct
7 Incorrect 2 ms 544 KB Output isn't correct
8 Incorrect 2 ms 544 KB Output isn't correct
9 Incorrect 1 ms 544 KB Output isn't correct
10 Incorrect 1 ms 648 KB Output isn't correct
11 Incorrect 3 ms 648 KB Output isn't correct
12 Incorrect 2 ms 648 KB Output isn't correct
13 Incorrect 3 ms 648 KB Output isn't correct
14 Incorrect 2 ms 648 KB Output isn't correct
15 Incorrect 3 ms 648 KB Output isn't correct
16 Incorrect 23 ms 1180 KB Output isn't correct
17 Incorrect 20 ms 1308 KB Output isn't correct
18 Incorrect 19 ms 1308 KB Output isn't correct
19 Incorrect 20 ms 1308 KB Output isn't correct
20 Incorrect 9 ms 1308 KB Output isn't correct
21 Incorrect 73 ms 2532 KB Output isn't correct
22 Incorrect 74 ms 2532 KB Output isn't correct
23 Incorrect 74 ms 2664 KB Output isn't correct
24 Incorrect 86 ms 2664 KB Output isn't correct
25 Incorrect 71 ms 3572 KB Output isn't correct
26 Incorrect 105 ms 3572 KB Output isn't correct
27 Incorrect 73 ms 3572 KB Output isn't correct
28 Incorrect 75 ms 3572 KB Output isn't correct
29 Incorrect 76 ms 3572 KB Output isn't correct
30 Incorrect 38 ms 3572 KB Output isn't correct
31 Incorrect 1 ms 3572 KB Output isn't correct
32 Incorrect 2 ms 3572 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3572 KB Output is correct
2 Correct 2 ms 3572 KB Output is correct
3 Correct 1 ms 3572 KB Output is correct
4 Correct 1 ms 3572 KB Output is correct
5 Correct 1 ms 3572 KB Output is correct
6 Correct 2 ms 3572 KB Output is correct
7 Correct 2 ms 3572 KB Output is correct
8 Correct 2 ms 3572 KB Output is correct
9 Correct 1 ms 3572 KB Output is correct
10 Correct 2 ms 3572 KB Output is correct
11 Correct 3 ms 3572 KB Output is correct
12 Correct 2 ms 3572 KB Output is correct
13 Correct 2 ms 3572 KB Output is correct
14 Correct 3 ms 3572 KB Output is correct
15 Correct 2 ms 3572 KB Output is correct
16 Correct 19 ms 3572 KB Output is correct
17 Correct 19 ms 3572 KB Output is correct
18 Correct 20 ms 3572 KB Output is correct
19 Correct 19 ms 3572 KB Output is correct
20 Correct 15 ms 3572 KB Output is correct
21 Correct 90 ms 3572 KB Output is correct
22 Correct 80 ms 3572 KB Output is correct
23 Correct 73 ms 3572 KB Output is correct
24 Correct 74 ms 3572 KB Output is correct
25 Correct 70 ms 3660 KB Output is correct
26 Correct 75 ms 3660 KB Output is correct
27 Correct 72 ms 3660 KB Output is correct
28 Correct 80 ms 3660 KB Output is correct
29 Correct 75 ms 3660 KB Output is correct
30 Correct 39 ms 3660 KB Output is correct
31 Correct 2 ms 3660 KB Output is correct
32 Correct 1 ms 3660 KB Output is correct