Submission #852073

# Submission time Handle Problem Language Result Execution time Memory
852073 2023-09-21T07:57:12 Z 8pete8 Gap (APIO16_gap) C++17
0 / 100
39 ms 4696 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
#include "gap.h"
using namespace std;
#define ll long long
#define f first
#define endl "\n"
//#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define ll long long
const int mxn=1e5,mod=1000000007,lg=20,root=1000,inf=1e18;
ll findGap(int T,int N){
    ll mn,mx;
    ll ans=0;
    ll lmn=1,lmx=1e18;
    if(T==1){
        vector<ll>v;
        for(int i=0;i<(N+1)/2;i++){
            MinMax(lmn,lmx,&mn,&mx);
            v.pb(mn);
            v.pb(mx);
            lmn=mn+1;
            lmx=mx-1;
        }
        sort(all(v));
        for(int i=1;i<N;i++)ans=max(ans,v[i]-v[i-1]);
        return ans;
    }
    ans=((mx-mn-1)+(N-2))/(N-2);//min max gap
    int add=0,cur=mn;
    for(int i=0;i<N;i++){
        MinMax(cur+1,cur+ans,&mn,&mx);
        if(mn==-1)add+=(ans);
        else cur=mx,ans=max(ans,add+(mn-cur));
    }
    return ans;
}

Compilation message

gap.cpp:30:54: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   30 | const int mxn=1e5,mod=1000000007,lg=20,root=1000,inf=1e18;
      |                                                      ^~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:48:13: warning: 'mx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     ans=((mx-mn-1)+(N-2))/(N-2);//min max gap
      |           ~~^~~
gap.cpp:48:13: warning: 'mn' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2404 KB Output is correct
4 Incorrect 0 ms 2392 KB Output isn't correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 8 ms 2832 KB Output is correct
17 Correct 8 ms 2844 KB Output is correct
18 Correct 8 ms 2836 KB Output is correct
19 Correct 8 ms 2836 KB Output is correct
20 Correct 9 ms 2980 KB Output is correct
21 Correct 35 ms 4000 KB Output is correct
22 Correct 39 ms 3980 KB Output is correct
23 Correct 32 ms 4004 KB Output is correct
24 Correct 32 ms 3992 KB Output is correct
25 Correct 28 ms 3984 KB Output is correct
26 Correct 31 ms 3992 KB Output is correct
27 Correct 33 ms 3988 KB Output is correct
28 Correct 31 ms 4000 KB Output is correct
29 Correct 35 ms 4000 KB Output is correct
30 Correct 28 ms 3824 KB Output is correct
31 Correct 1 ms 2484 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4696 KB Execution killed with signal 8
2 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 2404 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
6 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
7 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
8 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
9 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
10 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
16 Runtime error 3 ms 2752 KB Execution failed because the return code was nonzero
17 Runtime error 3 ms 2584 KB Execution failed because the return code was nonzero
18 Runtime error 3 ms 2752 KB Execution failed because the return code was nonzero
19 Runtime error 4 ms 2580 KB Execution failed because the return code was nonzero
20 Runtime error 2 ms 2568 KB Execution failed because the return code was nonzero
21 Runtime error 12 ms 2808 KB Execution failed because the return code was nonzero
22 Runtime error 12 ms 3092 KB Execution failed because the return code was nonzero
23 Runtime error 13 ms 2856 KB Execution failed because the return code was nonzero
24 Runtime error 12 ms 2984 KB Execution failed because the return code was nonzero
25 Runtime error 9 ms 2852 KB Execution failed because the return code was nonzero
26 Runtime error 12 ms 2904 KB Execution failed because the return code was nonzero
27 Runtime error 12 ms 2836 KB Execution failed because the return code was nonzero
28 Runtime error 12 ms 2852 KB Execution failed because the return code was nonzero
29 Runtime error 12 ms 2836 KB Execution failed because the return code was nonzero
30 Runtime error 7 ms 2852 KB Execution failed because the return code was nonzero
31 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
32 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero