Submission #615374

# Submission time Handle Problem Language Result Execution time Memory
615374 2022-07-31T08:40:41 Z Omar_Fakhry Gap (APIO16_gap) C++17
0 / 100
41 ms 1104 KB
//بسم الله الرحمن الرحيم
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pi 3.14159265358979323846
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define For(start,end,step) for(ll i=start;i<=end;i+=step)
#define For2(start,end,step) for(ll j=start;j<=end;j+=step)
#define mult(x,y) x*(y-1)
#define ALL(x) x.begin(), x.end()
using namespace std;
using namespace __gnu_pbds;
const ll mod=1e9+7;
bool prime(ll n)
{
for(int i=2;i*i<=n;i++)if(n%i==0)return 0;
return 1;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll po(ll x,ll y)
{
    if(y==0) return 1;
    ll ret=po(x,y/2);
    ret=(ret*ret);
    if(y&1)
        return (x*ret);
    return ret;
}
ll sigma(ll s,ll e,ll num_elements)
{
    ll res1=s+e;
    ll res=(((s+e)/2)*(num_elements));
    if(res1%2)res+=num_elements/2;
    return res;
}
ll mod_inverse(ll x)
{
    return po(x,mod-2);
}
string bin(ll x)
{
    string str="";
    while(x)
    {
        if(x%2)
        {
            str+='1';
        }
        else
        {
            str+='0';
        }
        x/=2;
    }
    return str;
}
ll GP(ll base,ll power,ll step)
{
    return (po(base,power+step)+mod-1)%mod*mod_inverse(po(base,step)-1)%mod;
}
ll fact(ll x)
{
    if(x<2)return 1;
    return x*fact(x-1)%mod;
}
ll ncr(ll x,ll y)
{
    return fact(x)*mod_inverse(fact(y)*fact(x-y)%mod)%mod;
}
bool valid(ll x,ll y,ll n,ll m)
{
    return(x>=0&&y>=0&&x<n&&y<m);
}
int dx[8]= {0,0,1,-1,-1,1,1,-1};
int dy[8]= {-1,1,0,0,-1,1,-1,1};

const int N=605;

ll mn,mx;
void MinMax(ll s,ll t,ll &mn,ll &mx)
{
    cin>>mn>>mx;
    return;
}
ll findGap(int T,int n)
{
    ll start_num=0,end_num=1e18;
    vector<int>vec;
    for(int i=0;i<n/2+n%2;i++)
    {
        MinMax(start_num,end_num,mn,mx);
        vec.push_back(mn);
        vec.push_back(mx);
        start_num=mn+1;
        end_num=mx+1;
    }
    sort(vec.begin(),vec.end());
    int ans=0;
    for(int i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]);
    return ans;
}
/*
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
}
*/

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:102:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |     for(int i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]);
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
3 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
4 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
5 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
6 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
7 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
8 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
9 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
10 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
11 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
12 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
13 Execution timed out 1 ms 336 KB Time limit exceeded (wall clock)
14 Execution timed out 1 ms 336 KB Time limit exceeded (wall clock)
15 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
16 Execution timed out 7 ms 464 KB Time limit exceeded (wall clock)
17 Execution timed out 7 ms 464 KB Time limit exceeded (wall clock)
18 Execution timed out 11 ms 464 KB Time limit exceeded (wall clock)
19 Execution timed out 5 ms 464 KB Time limit exceeded (wall clock)
20 Execution timed out 3 ms 464 KB Time limit exceeded (wall clock)
21 Execution timed out 30 ms 1028 KB Time limit exceeded (wall clock)
22 Execution timed out 41 ms 1076 KB Time limit exceeded (wall clock)
23 Execution timed out 19 ms 1060 KB Time limit exceeded (wall clock)
24 Execution timed out 29 ms 996 KB Time limit exceeded (wall clock)
25 Execution timed out 20 ms 1068 KB Time limit exceeded (wall clock)
26 Execution timed out 31 ms 1012 KB Time limit exceeded (wall clock)
27 Execution timed out 22 ms 1032 KB Time limit exceeded (wall clock)
28 Execution timed out 26 ms 1080 KB Time limit exceeded (wall clock)
29 Execution timed out 34 ms 1056 KB Time limit exceeded (wall clock)
30 Execution timed out 11 ms 1088 KB Time limit exceeded (wall clock)
31 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
32 Execution timed out 1 ms 228 KB Time limit exceeded (wall clock)
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
3 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
4 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
5 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
6 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
7 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
8 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
9 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
10 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
11 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
12 Execution timed out 1 ms 336 KB Time limit exceeded (wall clock)
13 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
14 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
15 Execution timed out 1 ms 336 KB Time limit exceeded (wall clock)
16 Execution timed out 9 ms 464 KB Time limit exceeded (wall clock)
17 Execution timed out 5 ms 464 KB Time limit exceeded (wall clock)
18 Execution timed out 5 ms 500 KB Time limit exceeded (wall clock)
19 Execution timed out 5 ms 428 KB Time limit exceeded (wall clock)
20 Execution timed out 6 ms 464 KB Time limit exceeded (wall clock)
21 Execution timed out 29 ms 976 KB Time limit exceeded (wall clock)
22 Execution timed out 19 ms 1012 KB Time limit exceeded (wall clock)
23 Execution timed out 19 ms 980 KB Time limit exceeded (wall clock)
24 Execution timed out 28 ms 968 KB Time limit exceeded (wall clock)
25 Execution timed out 14 ms 1104 KB Time limit exceeded (wall clock)
26 Execution timed out 22 ms 1044 KB Time limit exceeded (wall clock)
27 Execution timed out 19 ms 1060 KB Time limit exceeded (wall clock)
28 Execution timed out 18 ms 1104 KB Time limit exceeded (wall clock)
29 Execution timed out 26 ms 1044 KB Time limit exceeded (wall clock)
30 Execution timed out 13 ms 976 KB Time limit exceeded (wall clock)
31 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
32 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)