Submission #671098

# Submission time Handle Problem Language Result Execution time Memory
671098 2022-12-12T01:29:52 Z AdamGS Gap (APIO16_gap) C++17
100 / 100
56 ms 2632 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18;
ll findGap(int t, int n) {
        if(t==2) {
                ll mi, ma;
                MinMax(0, INF, &mi, &ma);
                ll x=(ma-mi+n-2)/(n-1), ans=x;
                ll lst=mi;
                for(ll i=mi; i<=ma; i+=x+1) {
                        ll a, b;
                        MinMax(i, i+x, &a, &b);
                        if(a==-1) continue;
                        ans=max(ans, a-lst);
                        lst=b;
                }
                return ans;
        }
        vector<ll>A, B;
        ll mi=0, ma=INF;
        rep(i, (n+1)/2)  {
                ll a, b;
                MinMax(mi, ma, &a, &b);
                if(a==-1) break;
                A.pb(a);
                B.pb(b);
                mi=a+1;
                ma=b-1;
        }
        reverse(all(B));
        for(auto i : B) A.pb(i);
        ll ans=0;
        rep(i, A.size()-1) ans=max(ans, A[i+1]-A[i]);
        return ans;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
gap.cpp:38:9: note: in expansion of macro 'rep'
   38 |         rep(i, A.size()-1) ans=max(ans, A[i+1]-A[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 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 1 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 976 KB Output is correct
17 Correct 9 ms 952 KB Output is correct
18 Correct 9 ms 952 KB Output is correct
19 Correct 9 ms 976 KB Output is correct
20 Correct 7 ms 976 KB Output is correct
21 Correct 37 ms 2608 KB Output is correct
22 Correct 37 ms 2624 KB Output is correct
23 Correct 34 ms 2628 KB Output is correct
24 Correct 34 ms 2632 KB Output is correct
25 Correct 31 ms 2552 KB Output is correct
26 Correct 33 ms 2592 KB Output is correct
27 Correct 34 ms 2552 KB Output is correct
28 Correct 34 ms 2624 KB Output is correct
29 Correct 34 ms 2540 KB Output is correct
30 Correct 27 ms 2600 KB Output is correct
31 Correct 1 ms 212 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 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 208 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 464 KB Output is correct
17 Correct 12 ms 508 KB Output is correct
18 Correct 11 ms 464 KB Output is correct
19 Correct 12 ms 424 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 48 ms 1084 KB Output is correct
22 Correct 56 ms 1120 KB Output is correct
23 Correct 47 ms 1024 KB Output is correct
24 Correct 48 ms 1064 KB Output is correct
25 Correct 52 ms 992 KB Output is correct
26 Correct 51 ms 1024 KB Output is correct
27 Correct 54 ms 1080 KB Output is correct
28 Correct 47 ms 976 KB Output is correct
29 Correct 48 ms 1056 KB Output is correct
30 Correct 23 ms 1068 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct