답안 #140834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140834 2019-08-05T14:18:58 Z Autoratch Gap (APIO16_gap) C++14
100 / 100
88 ms 5228 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
/*
void MinMax(long long x,long long y,long long* a,long long* b)
{
    cout <<  x << ' ' << y << endl;
    int aa,bb;
    cin >>  aa >> bb;
    *a = aa,*b = bb;
}
*/
vector<long long> a;

long long findGap(int t,int n)
{
    long long mn,mx,ans = 0;

    MinMax(0,1e18,&mn,&mx);

    if(t==1)
    {
        a.push_back(mn),a.push_back(mx);
        int l = 1,r = n-2;
        while(l<=r)
        {
            MinMax(mn+1,mx-1,&mn,&mx);
            a.push_back(mn),a.push_back(mx);
            l++,r--;
        }
    }        
    else
    {
        long long each = (mx-mn+n-2)/(n-1);
        ans = each;
        for(long long x = mn;x <= mx;x+=each+1)
        {
            long long xa,xb;
            MinMax(x,x+each,&xa,&xb);
            a.push_back(xa),a.push_back(xb);
        }
    }

    sort(a.begin(),a.end());

    for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);

    return ans;
}
/*
int main()
{
    int x;
    cin >> x;
    cout << findGap(0,x);
}*/

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:46:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
                   ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 17 ms 1400 KB Output is correct
17 Correct 19 ms 1400 KB Output is correct
18 Correct 17 ms 1400 KB Output is correct
19 Correct 17 ms 1400 KB Output is correct
20 Correct 13 ms 1144 KB Output is correct
21 Correct 63 ms 4208 KB Output is correct
22 Correct 63 ms 4208 KB Output is correct
23 Correct 64 ms 4080 KB Output is correct
24 Correct 68 ms 4208 KB Output is correct
25 Correct 54 ms 3568 KB Output is correct
26 Correct 62 ms 4076 KB Output is correct
27 Correct 63 ms 4336 KB Output is correct
28 Correct 62 ms 4076 KB Output is correct
29 Correct 62 ms 4076 KB Output is correct
30 Correct 49 ms 2928 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 23 ms 1652 KB Output is correct
17 Correct 23 ms 1648 KB Output is correct
18 Correct 23 ms 1652 KB Output is correct
19 Correct 23 ms 1652 KB Output is correct
20 Correct 11 ms 1396 KB Output is correct
21 Correct 87 ms 5228 KB Output is correct
22 Correct 86 ms 5204 KB Output is correct
23 Correct 87 ms 5100 KB Output is correct
24 Correct 88 ms 5228 KB Output is correct
25 Correct 79 ms 4576 KB Output is correct
26 Correct 87 ms 5228 KB Output is correct
27 Correct 87 ms 5192 KB Output is correct
28 Correct 88 ms 5228 KB Output is correct
29 Correct 87 ms 5096 KB Output is correct
30 Correct 43 ms 4036 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct