Submission #240401

# Submission time Handle Problem Language Result Execution time Memory
240401 2020-06-19T14:41:35 Z ctziapo Gap (APIO16_gap) C++14
100 / 100
78 ms 3284 KB
#include "gap.h"
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;


long long findGap(int T, int N)
{
    if(T==1){

	long long int mi,ma;
    int n=N;
	MinMax(1,1000000000000000000,&mi,&ma);

    long long int a[n+3];
	//cout<<mi<<" "<<ma<<endl;
	a[1]=mi;
	a[n]=ma;

	for(int i=2;i<=n/2;i++){
        //cout<<1;
        mi++;
        ma--;
        //cout<<" 22 "<<mi<<" "<<ma;
        MinMax(mi,ma,&mi,&ma);
      //  cout<<mi<<" "<<ma<<endl;
        a[i]=mi;
        a[n-i+1]=ma;
	}
	mi++;
	ma--;
	if(n%2==1){
        MinMax(mi,ma,&mi,&ma);
        a[n/2+1]=mi;
	}
	long long int ans=0;
	for(int i=2;i<=n;i++){
        ans=max(ans,a[i]-a[i-1]);
	}
	return ans;


    }
    else
    {

        long long int mi,ma;
        int n=N;
        MinMax(1,2000000000000000000,&mi,&ma);

        long long int a[n+3];

        vector <long long int > v;
        v.push_back(mi);
        long long int d=(ma-mi+1)/n;
        d++;
        long long int s=mi;

        long long int ans=0;
        s++;
        while(s<=ma){

            long long int t1,t2;
            MinMax(s,min(s-1+d,ma),&t1,&t2);

            if(t1!=-1)
                v.push_back(t1);
            if(t2!=-1)
                v.push_back(t2);
           // cout<<t1<<" "<<t2;

            s+=(d);
        }
        v.push_back(ma);

        for(int i=1;i<v.size();i++){
            ans=max(ans,v[i]-v[i-1]);
        }
        return ans;
    }


}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:78:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=1;i<v.size();i++){
                     ~^~~~~~~~~
gap.cpp:53:23: warning: unused variable 'a' [-Wunused-variable]
         long long int a[n+3];
                       ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 16 ms 768 KB Output is correct
17 Correct 16 ms 640 KB Output is correct
18 Correct 17 ms 744 KB Output is correct
19 Correct 16 ms 640 KB Output is correct
20 Correct 12 ms 640 KB Output is correct
21 Correct 51 ms 1912 KB Output is correct
22 Correct 55 ms 1820 KB Output is correct
23 Correct 59 ms 1912 KB Output is correct
24 Correct 59 ms 1912 KB Output is correct
25 Correct 50 ms 1912 KB Output is correct
26 Correct 51 ms 1912 KB Output is correct
27 Correct 54 ms 1912 KB Output is correct
28 Correct 51 ms 1912 KB Output is correct
29 Correct 57 ms 1912 KB Output is correct
30 Correct 43 ms 1912 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 21 ms 916 KB Output is correct
17 Correct 20 ms 896 KB Output is correct
18 Correct 20 ms 896 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 11 ms 512 KB Output is correct
21 Correct 70 ms 2416 KB Output is correct
22 Correct 74 ms 2244 KB Output is correct
23 Correct 70 ms 2424 KB Output is correct
24 Correct 69 ms 2288 KB Output is correct
25 Correct 62 ms 3284 KB Output is correct
26 Correct 72 ms 2288 KB Output is correct
27 Correct 71 ms 2288 KB Output is correct
28 Correct 78 ms 2288 KB Output is correct
29 Correct 71 ms 2260 KB Output is correct
30 Correct 38 ms 1528 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct