답안 #45457

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45457 2018-04-14T07:03:39 Z Unit Gap (APIO16_gap) C++14
100 / 100
82 ms 3544 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll findGap(int t,int n)
{
    ll s[100010];
    if(t == 1)
    {
        ll l = -1,r = 1001001001001001001;
        for(int i = 0; i < (n + 1) / 2; i++)
        {
            ll MAX,MIN;
            MinMax(l,r,&MIN,&MAX);
            s[i] = MIN;
            s[n - 1 - i] = MAX;
            l = MIN + 1;
            r = MAX - 1;
        }
        ll res = 0;
        for(int i = 1; i < n; i++)res = max(res,s[i] - s[i - 1]);
        return res;
    }
    else
    {
        ll L,R;
        MinMax(-1,1001001001001001001,&L,&R);
        vector<ll> ele;
        ele.push_back(L);
        ele.push_back(R);
        L++,R--;
        ll MIN,MAX,dif = R - L + 1;
        ll now = L;
        for(int i = 0; i < dif % n; i++)
        {
            MinMax(now,now + dif / n,&MIN,&MAX);
            if(MIN != -1)
            {
                ele.push_back(MIN);
                ele.push_back(MAX);
            }
            now = now + dif / n + 1;
        }
        for(int i = 0; i < n - dif % n; i++)
        {
            MinMax(now,now + dif / n - 1,&MIN,&MAX);
            if(MIN != -1)
            {
                ele.push_back(MIN);
                ele.push_back(MAX);
            }
            now = now + dif / n;
        }
        sort(ele.begin(),ele.end());
        ll res = 0;
        for(int i = 1; i < (int)ele.size(); i++)res = max(res,ele[i] - ele[i - 1]);
        return res;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 3 ms 680 KB Output is correct
12 Correct 3 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 3 ms 680 KB Output is correct
15 Correct 3 ms 680 KB Output is correct
16 Correct 15 ms 948 KB Output is correct
17 Correct 15 ms 948 KB Output is correct
18 Correct 15 ms 952 KB Output is correct
19 Correct 15 ms 952 KB Output is correct
20 Correct 12 ms 952 KB Output is correct
21 Correct 56 ms 2052 KB Output is correct
22 Correct 58 ms 2104 KB Output is correct
23 Correct 60 ms 2104 KB Output is correct
24 Correct 82 ms 2104 KB Output is correct
25 Correct 49 ms 2108 KB Output is correct
26 Correct 56 ms 2132 KB Output is correct
27 Correct 57 ms 2132 KB Output is correct
28 Correct 56 ms 2132 KB Output is correct
29 Correct 57 ms 2132 KB Output is correct
30 Correct 42 ms 2132 KB Output is correct
31 Correct 2 ms 2132 KB Output is correct
32 Correct 2 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2132 KB Output is correct
2 Correct 2 ms 2132 KB Output is correct
3 Correct 2 ms 2132 KB Output is correct
4 Correct 2 ms 2132 KB Output is correct
5 Correct 2 ms 2132 KB Output is correct
6 Correct 2 ms 2132 KB Output is correct
7 Correct 2 ms 2132 KB Output is correct
8 Correct 2 ms 2132 KB Output is correct
9 Correct 2 ms 2132 KB Output is correct
10 Correct 2 ms 2132 KB Output is correct
11 Correct 3 ms 2132 KB Output is correct
12 Correct 3 ms 2132 KB Output is correct
13 Correct 3 ms 2132 KB Output is correct
14 Correct 3 ms 2132 KB Output is correct
15 Correct 3 ms 2132 KB Output is correct
16 Correct 21 ms 2132 KB Output is correct
17 Correct 21 ms 2132 KB Output is correct
18 Correct 20 ms 2132 KB Output is correct
19 Correct 21 ms 2132 KB Output is correct
20 Correct 10 ms 2132 KB Output is correct
21 Correct 78 ms 2520 KB Output is correct
22 Correct 80 ms 2524 KB Output is correct
23 Correct 79 ms 2524 KB Output is correct
24 Correct 80 ms 2524 KB Output is correct
25 Correct 77 ms 3544 KB Output is correct
26 Correct 79 ms 3544 KB Output is correct
27 Correct 78 ms 3544 KB Output is correct
28 Correct 78 ms 3544 KB Output is correct
29 Correct 78 ms 3544 KB Output is correct
30 Correct 45 ms 3544 KB Output is correct
31 Correct 2 ms 3544 KB Output is correct
32 Correct 2 ms 3544 KB Output is correct