Submission #843897

# Submission time Handle Problem Language Result Execution time Memory
843897 2023-09-04T16:42:35 Z Elvin_Fritl Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
 #include "gap.h"

#include <bits/stdc++.h>
using namespace std;


long long findGap(int t, int n)
{
    long long mn = 0 , mx = 1e18;
    vector<long long>v;
    int tr = (n+1)/2;
    t = min(t , tr);
    while(tr--)
    {
        MinMax(mn , mx , &mn , &mx);
        v.push_back(mn);
        if(mn != mx)
            v.push_back(mx);
        mn++;
        mx--;
    }
    sort(v.begin() , v.end());
    long long res = 0;
    for(int i=1;i<v.size();i++){
        res = max(v[i] , v[i-1] , res);
    }
	return res;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:24:18: 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<v.size();i++){
      |                 ~^~~~~~~~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
gap.cpp:25:38:   required from here
/usr/include/c++/10/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~