Submission #661124

# Submission time Handle Problem Language Result Execution time Memory
661124 2022-11-24T14:53:37 Z activedeltorre Gap (APIO16_gap) C++14
100 / 100
63 ms 3260 KB
#include "gap.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<long long>vec;
#include <stdlib.h>
long long findGap(int t, int n)
{
    if(t==1)
    {
        
    long long a,b,minim,maxim,diff,i;
    minim=0;
    maxim=1e18;
    for(i=1;i<=(n+1)/2;i++)
    {
        MinMax(minim,maxim,&a,&b);
        vec.push_back(a);
        vec.push_back(b);
        minim=a+1;
        maxim=b-1;
    }
    sort(vec.begin(),vec.end());
    long long suma=0;
    for(i=1;i<vec.size();i++)
    {
        suma=max(suma,vec[i]-vec[i-1]);
    }
	return suma;
    }
    else
    {
        long long a,b,minim,maxim,diff,i;
    MinMax(0,1e18,&minim,&maxim);
    diff=(maxim-minim-1)/n+1;
    vec.push_back(minim);
    vec.push_back(maxim);
    for(i=minim;i<maxim;i=i+diff)
    {
        MinMax(i+1,i+diff,&a,&b);
        if(a!=-1)
        {
            vec.push_back(a);
            vec.push_back(b);
        }
    }
    sort(vec.begin(),vec.end());
    long long suma=0;
    for(i=1;i<vec.size();i++)
    {
        suma=max(suma,vec[i]-vec[i-1]);
    }
	return suma;
    }
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:26:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(i=1;i<vec.size();i++)
      |             ~^~~~~~~~~~~
gap.cpp:13:31: warning: unused variable 'diff' [-Wunused-variable]
   13 |     long long a,b,minim,maxim,diff,i;
      |                               ^~~~
gap.cpp:50:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(i=1;i<vec.size();i++)
      |             ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 11 ms 812 KB Output is correct
17 Correct 11 ms 848 KB Output is correct
18 Correct 12 ms 848 KB Output is correct
19 Correct 10 ms 888 KB Output is correct
20 Correct 9 ms 848 KB Output is correct
21 Correct 42 ms 2200 KB Output is correct
22 Correct 40 ms 2172 KB Output is correct
23 Correct 41 ms 2196 KB Output is correct
24 Correct 49 ms 2208 KB Output is correct
25 Correct 36 ms 2196 KB Output is correct
26 Correct 42 ms 2204 KB Output is correct
27 Correct 43 ms 2236 KB Output is correct
28 Correct 44 ms 2240 KB Output is correct
29 Correct 52 ms 2132 KB Output is correct
30 Correct 36 ms 2184 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 13 ms 884 KB Output is correct
17 Correct 13 ms 808 KB Output is correct
18 Correct 13 ms 848 KB Output is correct
19 Correct 15 ms 876 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 54 ms 2240 KB Output is correct
22 Correct 63 ms 2176 KB Output is correct
23 Correct 55 ms 2136 KB Output is correct
24 Correct 57 ms 2188 KB Output is correct
25 Correct 56 ms 3260 KB Output is correct
26 Correct 61 ms 2172 KB Output is correct
27 Correct 56 ms 2208 KB Output is correct
28 Correct 55 ms 2152 KB Output is correct
29 Correct 53 ms 2308 KB Output is correct
30 Correct 28 ms 1424 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct