Submission #25590

# Submission time Handle Problem Language Result Execution time Memory
25590 2017-06-23T06:47:37 Z kajebiii Gap (APIO16_gap) C++14
30 / 100
136 ms 6592 KB
#include "gap.h"

#include <algorithm>
#include <stdio.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;


const ll MINV = 0, MAXV = 1e18;
const int MAX_N = 1e5 + 100;

ll minV, maxV;

ll Nr[MAX_N][2], Ans[MAX_N];
long long findGap(int T, int N)
{
    if(T == 1) {
        ll ans = 0;
        minV = MINV, maxV = MAXV;        
        int li = 0, ri = N-1;
        for(int i=0; i<(N+1)/2; i++) {
            ll l, r;
            MinMax(minV, maxV, &l, &r);
            Ans[li++] = l;
            Ans[ri--] = r;
            minV = l+1; maxV = r-1;
        }
        for(int i=0; i+1<N; i++)
            ans = max(ans, Ans[i+1] - Ans[i]);
        return ans;
    }
    if(T == 2) {
        MinMax(MINV, MAXV, &minV, &maxV);
        ll diff = (maxV - minV + N-1) / N;
        ll ans = 0, lastR = -1;
        bool isBlank = false;
        for(int i=0; i<N; i++) {
            ll l = min(maxV, minV + i * diff);
            ll r = min(maxV, minV + (i+1) * diff - 1);
            MinMax(l, r, &Nr[i][0], &Nr[i][1]);
            printf("%lld %lld -> %lld %lld\n", l, r, Nr[i][0], Nr[i][1]);
            if(Nr[i][0] >= 0) {
                if(lastR != -1) ans = max(ans, Nr[i][0] - lastR);
                lastR = Nr[i][1];
            }else{
                isBlank = true;
            }
        }
        return ans;
    }
	return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:47:14: warning: variable 'isBlank' set but not used [-Wunused-but-set-variable]
         bool isBlank = false;
              ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6592 KB Output is correct
2 Correct 0 ms 6592 KB Output is correct
3 Correct 0 ms 6592 KB Output is correct
4 Correct 0 ms 6592 KB Output is correct
5 Correct 0 ms 6592 KB Output is correct
6 Correct 0 ms 6592 KB Output is correct
7 Correct 0 ms 6592 KB Output is correct
8 Correct 0 ms 6592 KB Output is correct
9 Correct 0 ms 6592 KB Output is correct
10 Correct 0 ms 6592 KB Output is correct
11 Correct 0 ms 6592 KB Output is correct
12 Correct 0 ms 6592 KB Output is correct
13 Correct 0 ms 6592 KB Output is correct
14 Correct 0 ms 6592 KB Output is correct
15 Correct 0 ms 6592 KB Output is correct
16 Correct 16 ms 6592 KB Output is correct
17 Correct 16 ms 6592 KB Output is correct
18 Correct 6 ms 6592 KB Output is correct
19 Correct 16 ms 6592 KB Output is correct
20 Correct 9 ms 6592 KB Output is correct
21 Correct 63 ms 6592 KB Output is correct
22 Correct 73 ms 6592 KB Output is correct
23 Correct 49 ms 6592 KB Output is correct
24 Correct 63 ms 6592 KB Output is correct
25 Correct 46 ms 6592 KB Output is correct
26 Correct 56 ms 6592 KB Output is correct
27 Correct 66 ms 6592 KB Output is correct
28 Correct 66 ms 6592 KB Output is correct
29 Correct 49 ms 6592 KB Output is correct
30 Correct 36 ms 6592 KB Output is correct
31 Correct 0 ms 6592 KB Output is correct
32 Correct 0 ms 6592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 6592 KB Expected EOLN
2 Incorrect 0 ms 6592 KB Expected EOLN
3 Incorrect 0 ms 6592 KB Expected EOLN
4 Incorrect 0 ms 6592 KB Expected EOLN
5 Incorrect 0 ms 6592 KB Expected EOLN
6 Incorrect 0 ms 6592 KB Expected EOLN
7 Incorrect 0 ms 6592 KB Expected EOLN
8 Incorrect 0 ms 6592 KB Expected EOLN
9 Incorrect 0 ms 6592 KB Expected EOLN
10 Incorrect 0 ms 6592 KB Expected EOLN
11 Incorrect 0 ms 6592 KB Expected EOLN
12 Incorrect 0 ms 6592 KB Expected EOLN
13 Incorrect 0 ms 6592 KB Expected EOLN
14 Incorrect 0 ms 6592 KB Expected EOLN
15 Incorrect 0 ms 6592 KB Expected EOLN
16 Incorrect 29 ms 6592 KB Expected EOLN
17 Incorrect 36 ms 6592 KB Expected EOLN
18 Incorrect 36 ms 6592 KB Expected EOLN
19 Incorrect 26 ms 6592 KB Expected EOLN
20 Incorrect 23 ms 6592 KB Expected EOLN
21 Incorrect 116 ms 6592 KB Expected EOLN
22 Incorrect 103 ms 6592 KB Expected EOLN
23 Incorrect 106 ms 6592 KB Expected EOLN
24 Incorrect 106 ms 6592 KB Expected EOLN
25 Incorrect 106 ms 6592 KB Expected EOLN
26 Incorrect 136 ms 6592 KB Expected EOLN
27 Incorrect 123 ms 6592 KB Expected EOLN
28 Incorrect 123 ms 6592 KB Expected EOLN
29 Incorrect 133 ms 6592 KB Expected EOLN
30 Incorrect 76 ms 6592 KB Expected EOLN
31 Incorrect 0 ms 6592 KB Expected EOLN
32 Incorrect 0 ms 6592 KB Expected EOLN