Submission #591372

# Submission time Handle Problem Language Result Execution time Memory
591372 2022-07-07T10:52:21 Z MohamedFaresNebili Gap (APIO16_gap) C++14
100 / 100
54 ms 3232 KB
#include <bits/stdc++.h>
#include "gap.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
 
            using namespace std;
 
            using ll = long long;
            using ld = long double;
 
            #define ff first
            #define ss second
            #define pb push_back
            #define all(x) (x).begin(), (x).end()
            #define lb lower_bound
 
            ll findGap(int T, int N) {
                if(T == 1) {
                    vector<ll> A(N + 2);
                    A[0] = -1ll, A[N + 1] = 1000000000ll * 1000000000ll + 1ll;
                    for(ll l = 1; l <= (N + 1) / 2; l++) {
                        MinMax(A[l - 1] + 1, A[N - l + 2] - 1, &A[l], &A[N - l + 1]);
                    }
                    ll res = 0;
                    for(ll l = 2; l <= N; l++)
                        res = max(res, A[l] - A[l - 1]);
                    return res;
                }
                vector<ll> S; ll mn = -1, mx = -1, res = 0;
                MinMax(0ll, 1000000000000000000ll, &mn, &mx);
                ll L = mn, R = mx; ll md = (R - L + N) / N;
                S.push_back(L);
                while(L < R) {
                    MinMax(L + 1, min(R - 1, L + md), &mn, &mx); L += md;
                    if(mn == -1 && mx == -1) continue;
                    S.push_back(mn); S.push_back(mx); 
                }
                S.push_back(R);
                for(int l = 1; l < S.size(); l++)
                    res = max(res, S[l] - S[l - 1]);
                return res;
            }

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:40:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                 for(int l = 1; l < S.size(); l++)
      |                                ~~^~~~~~~~~~
# 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 1 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 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 9 ms 720 KB Output is correct
17 Correct 8 ms 720 KB Output is correct
18 Correct 8 ms 636 KB Output is correct
19 Correct 8 ms 684 KB Output is correct
20 Correct 6 ms 720 KB Output is correct
21 Correct 34 ms 1864 KB Output is correct
22 Correct 35 ms 1832 KB Output is correct
23 Correct 34 ms 1864 KB Output is correct
24 Correct 35 ms 1836 KB Output is correct
25 Correct 29 ms 1828 KB Output is correct
26 Correct 34 ms 1804 KB Output is correct
27 Correct 35 ms 1840 KB Output is correct
28 Correct 33 ms 1824 KB Output is correct
29 Correct 37 ms 1812 KB Output is correct
30 Correct 26 ms 1824 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 1 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 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 336 KB Output is correct
16 Correct 12 ms 848 KB Output is correct
17 Correct 12 ms 900 KB Output is correct
18 Correct 12 ms 896 KB Output is correct
19 Correct 13 ms 848 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 50 ms 2188 KB Output is correct
22 Correct 54 ms 2160 KB Output is correct
23 Correct 48 ms 2244 KB Output is correct
24 Correct 50 ms 2208 KB Output is correct
25 Correct 45 ms 3232 KB Output is correct
26 Correct 48 ms 2204 KB Output is correct
27 Correct 50 ms 2156 KB Output is correct
28 Correct 48 ms 2336 KB Output is correct
29 Correct 50 ms 2176 KB Output is correct
30 Correct 25 ms 1444 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct