Submission #625151

# Submission time Handle Problem Language Result Execution time Memory
625151 2022-08-09T13:46:12 Z PoonYaPat Gap (APIO16_gap) C++14
0 / 100
57 ms 3196 KB
#include "gap.h"
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
 
vector<pll> v;
vector<ll> k;
ll mx,mn,ans;
 
ll findGap(int T, int n) {
    if (T==1) {
        mn=-1, mx=1e18+1;
        while (k.size()<n) {
            MinMax(mn+1,mx-1,&mn,&mx);
            if (mn==mx) k.push_back(mn);
            else {
                k.push_back(mn);
                k.push_back(mx);
            }
        }
        sort(k.begin(),k.end());
        for (int i=1; i<k.size(); ++i) ans=max(ans,k[i]-k[i-1]);
    } else {
        MinMax(0,1e18,&mn,&mx);
        ll mmin=mn,mmax=mx;
        v.push_back(pll(mn,mn));
 
        ll wide=(mx-mn+n-3)/(n-2);
        for (int i=0; i<n-1; ++i) {
            MinMax(mmin+1+wide*i,min(mmin+wide*(i+1),mmax-1),&mn,&mx);
            if (mn!=-1) v.push_back(pll(mn,mx));
        }
        v.push_back(pll(mmax,mmax));
 
        for (int i=1; i<v.size(); ++i) ans=max(ans,v[i].first-v[i-1].second);
    }
    return ans;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:15:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |         while (k.size()<n) {
      |                ~~~~~~~~^~
gap.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int i=1; i<k.size(); ++i) ans=max(ans,k[i]-k[i-1]);
      |                       ~^~~~~~~~~
gap.cpp:37:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i=1; i<v.size(); ++i) ans=max(ans,v[i].first-v[i-1].second);
      |                       ~^~~~~~~~~
# 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 2 ms 336 KB Output is correct
13 Correct 1 ms 236 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 848 KB Output is correct
17 Correct 9 ms 812 KB Output is correct
18 Correct 10 ms 848 KB Output is correct
19 Correct 9 ms 848 KB Output is correct
20 Correct 8 ms 872 KB Output is correct
21 Correct 40 ms 2248 KB Output is correct
22 Correct 38 ms 2144 KB Output is correct
23 Correct 39 ms 2368 KB Output is correct
24 Correct 39 ms 2164 KB Output is correct
25 Correct 39 ms 2204 KB Output is correct
26 Correct 38 ms 2204 KB Output is correct
27 Correct 42 ms 2200 KB Output is correct
28 Correct 39 ms 2368 KB Output is correct
29 Correct 44 ms 2208 KB Output is correct
30 Correct 34 ms 2204 KB Output is correct
31 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
32 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 8
2 Runtime error 1 ms 208 KB Execution failed because the return code was nonzero
3 Runtime error 1 ms 208 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
5 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
6 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
7 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
8 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
9 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
10 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
16 Runtime error 13 ms 896 KB Execution failed because the return code was nonzero
17 Runtime error 13 ms 848 KB Execution failed because the return code was nonzero
18 Runtime error 15 ms 856 KB Execution failed because the return code was nonzero
19 Runtime error 13 ms 848 KB Execution failed because the return code was nonzero
20 Runtime error 6 ms 520 KB Execution failed because the return code was nonzero
21 Runtime error 57 ms 2200 KB Execution failed because the return code was nonzero
22 Runtime error 51 ms 2192 KB Execution failed because the return code was nonzero
23 Runtime error 49 ms 2240 KB Execution failed because the return code was nonzero
24 Runtime error 52 ms 2136 KB Execution failed because the return code was nonzero
25 Runtime error 48 ms 3196 KB Execution failed because the return code was nonzero
26 Runtime error 51 ms 2156 KB Execution failed because the return code was nonzero
27 Runtime error 49 ms 2184 KB Execution failed because the return code was nonzero
28 Runtime error 51 ms 2216 KB Execution failed because the return code was nonzero
29 Runtime error 51 ms 2424 KB Execution failed because the return code was nonzero
30 Runtime error 34 ms 1448 KB Execution failed because the return code was nonzero
31 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
32 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero