Submission #484131

# Submission time Handle Problem Language Result Execution time Memory
484131 2021-11-02T07:09:24 Z beaconmc Gap (APIO16_gap) C++14
100 / 100
68 ms 2324 KB
#include <bits/stdc++.h>
#include "gap.h"
typedef long long ll;
#define FOR(i, x, y) for(ll i=(x); i<(y); i++)
#define MAX18 1000000000000000000
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
  
#define ordered_set tree<ll, null_type,greater_equal<int>, rb_tree_tag,tree_order_statistics_node_update>


ll findGap(int t, int n){
    if (t==1){
        vector<ll> sussy;
        sussy.clear();
        ll l=0; ll r=MAX18;
        ll lc=0; ll rc=0;
        while (l<r){
            MinMax(l,r,&lc,&rc);
            if (lc!=-1){
                sussy.push_back(lc);
                if (lc!=rc) sussy.push_back(rc);
            }
            if (sussy.size() == n) break;
            l = lc+1; r=rc-1;
        }
        sort(sussy.begin(), sussy.end());
        ll maxi=0;
        FOR(i, 0, n-1) maxi = max(maxi, sussy[i+1]-sussy[i]);
        return maxi;   
    }
    vector<ll> sussy;
    sussy.clear();
    ll l=0; ll r=MAX18;
    ll lc=0; ll rc=0;
    MinMax(l,r,&lc,&rc);

    sussy.push_back(lc);sussy.push_back(rc);
    l = lc; r = lc;
    ll rightmost = rc;
    ll gap = (rc - lc-1)/(n-1)+1;
    while (r<rightmost){
        l = r+1;r = l+gap;
        MinMax(l,min(r, rightmost-1),&lc,&rc);
        if (lc!=-1){
            sussy.push_back(lc);
            if (lc!=rc)sussy.push_back(rc);
        }
    }

    sort(sussy.begin(), sussy.end());
    ll maxi=0;
    ll prv = sussy[0];
    for (auto&i : sussy){
        maxi = max(maxi, i-prv);
        prv = i;
    }
    return maxi;

}

/*
int main(){
}
*/

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:27:30: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             if (sussy.size() == n) break;
      |                 ~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 10 ms 892 KB Output is correct
17 Correct 11 ms 840 KB Output is correct
18 Correct 11 ms 840 KB Output is correct
19 Correct 14 ms 840 KB Output is correct
20 Correct 9 ms 840 KB Output is correct
21 Correct 44 ms 2200 KB Output is correct
22 Correct 41 ms 2196 KB Output is correct
23 Correct 46 ms 2180 KB Output is correct
24 Correct 47 ms 2324 KB Output is correct
25 Correct 38 ms 2196 KB Output is correct
26 Correct 41 ms 2196 KB Output is correct
27 Correct 42 ms 2236 KB Output is correct
28 Correct 42 ms 2200 KB Output is correct
29 Correct 47 ms 2160 KB Output is correct
30 Correct 40 ms 2236 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 13 ms 804 KB Output is correct
17 Correct 12 ms 792 KB Output is correct
18 Correct 14 ms 840 KB Output is correct
19 Correct 15 ms 800 KB Output is correct
20 Correct 8 ms 520 KB Output is correct
21 Correct 52 ms 2156 KB Output is correct
22 Correct 68 ms 2184 KB Output is correct
23 Correct 57 ms 2196 KB Output is correct
24 Correct 58 ms 2192 KB Output is correct
25 Correct 49 ms 2164 KB Output is correct
26 Correct 56 ms 2244 KB Output is correct
27 Correct 56 ms 2192 KB Output is correct
28 Correct 55 ms 2232 KB Output is correct
29 Correct 54 ms 2192 KB Output is correct
30 Correct 31 ms 1388 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct