# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
129067 | OptxPrime | Global Warming (CEOI18_glo) | C++11 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
glo
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define ans Answer
#define query Query
int a[200010],sol[200010];
int tail[200010];
/*bool cmp( int x, int y )
{
if( x > y ) return true;
return false;
}*/
/// Wa bez razloga
int pos( int lo,int hi, int val )
{
int ans=0;
while( lo<=hi ){
int mid=lo + (hi-lo)/2;
if( tail[mid] > val ){
ans=max( ans, mid );
lo=mid+1;
}
else hi=mid-1;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,x;
int res=0;
cin>>n>>x;
for( int i=1;i<=n;i++ ) cin>>a[i];
tail[1] = a[n] + x;
sol[n]=1;
int len=2;
for( int i=n-1;i>0;i-- ){
if( a[i] + x >= tail[1] ) {
tail[1] = a[i]+x, sol[i] = 1;
}
else if( a[i]+x < tail[len-1] ) tail[len++]=a[i]+x, sol[i] = len-1;
else{
int idx = pos( 1,len-1, a[i]+x )+1;
tail[idx] = a[i]+x;
sol[i]=idx;
}
}
res=len-1;
for(int i=0;i<len;i++) tail[i]=0;
tail[1]=a[1];
len=2;
for( int i=2;i<=n;i++ ){
if( a[i]+x < tail[1] ) res = max( res, sol[i] ); /// ne mozemo ga ljevo nadovezat
else if( a[i] + x > tail[len-1] ) {
res=max( res, len + sol[i] - 1 ) ; ///-1 jer ga racunamo dvaput
}
else{
int idx = lower_bound( tail+1, tail+len, a[i]+x ) - tail;
res=max( res, idx + sol[i] - 1 );
}
if( a[i] < tail[1] ) tail[1]=a[i];
else if( a[i] > tail[len-1] ) tail[len++]=a[i];
else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail;
}
cout<<res<<endl;
return 0;
}
Compilation message (stderr)
glo.cpp:84:2: error: stray '\302' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:3: error: stray '\240' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:5: error: stray '\302' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:6: error: stray '\240' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:8: error: stray '\302' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:9: error: stray '\240' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:11: error: stray '\302' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:12: error: stray '\240' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:14: error: stray '\302' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:15: error: stray '\240' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:17: error: stray '\302' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:84:18: error: stray '\240' in program else tail[i] = lower_bound( tail+1, tail+len, a[i] ) - tail; ^ glo.cpp:1:1: error: 'glo' does not name a type glo ^~~ In file included from /usr/include/c++/7/iosfwd:40:0, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/bits/postypes.h:98:11: error: 'ptrdiff_t' does not name a type typedef ptrdiff_t streamsize; // Signed integral type ^~~~~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:120:31: error: declaration of 'operator new' as non-function void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^ /usr/include/c++/7/new:120:25: error: 'size_t' is not a member of 'std' void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^~~~~~ /usr/include/c++/7/new:120:25: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:122:33: error: declaration of 'operator new []' as non-function void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^ /usr/include/c++/7/new:122:27: error: 'size_t' is not a member of 'std' void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^~~~~~ /usr/include/c++/7/new:122:27: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:134:25: error: declaration of 'operator new' as non-function void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:134:25: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:134:25: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:134:33: error: expected primary-expression before 'const' void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~ /usr/include/c++/7/new:136:27: error: declaration of 'operator new []' as non-function void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:136:27: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:136:27: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:136:35: error: expected primary-expression before 'const' void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~ /usr/include/c++/7/new:168:32: error: declaration of 'operator new' as non-function inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:168:32: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:168:32: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:168:40: error: expected primary-expression before 'void' inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~ /usr/include/c++/7/new:170:34: error: declaration of 'operator new []' as non-function inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:170:34: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:170:34: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/new:170:42: error: expected primary-expression before 'void' inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_traits:362:31: error: 'std::size_t' has not been declared template<typename _Tp, std::size_t _Size> ^~~~~~ /usr/include/c++/7/type_traits:363:25: error: '_Size' was not declared in this scope struct is_array<_Tp[_Size]> ^~~~~ /usr/include/c++/7/type_traits:363:31: error: template argument 1 is invalid struct is_array<_Tp[_Size]> ^ /usr/include/c++/7/type_traits:561:42: error: 'nullptr_t' is not a member of 'std' struct __is_null_pointer_helper<std::nullptr_t> ^~~~~~~~~ /usr/include/c++/7/type_traits:561:42: note: suggested alternative: In file included from /usr/include/c++/7/bits/cxxabi_init_exception.h:38:0, from /usr/include/c++/7/bits/exception_ptr.h:38, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:444:29: note: 'nullptr_t' typedef decltype(nullptr) nullptr_t; ^~~~~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_traits:561:42: error: 'nullptr_t' is not a member of 'std' struct __is_null_pointer_helper<std::nullptr_t> ^~~~~~~~~ /usr/include/c++/7/type_traits:561:42: note: suggested alternative: In file included from /usr/include/c++/7/bits/cxxabi_init_exception.h:38:0, from /usr/include/c++/7/bits/exception_ptr.h:38, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:444:29: note: 'nullptr_t' typedef decltype(nullptr) nullptr_t; ^~~~~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_traits:561:51: error: template argument 1 is invalid struct __is_null_pointer_helper<std::nullptr_t> ^ /usr/include/c++/7/type_traits:1464:37: error: 'size_t' is not a member of 'std' : public integral_constant<std::size_t, __alignof__(_Tp)> { }; ^~~~~~ /usr/include/c++/7/type_traits:1464:37: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_traits:1464:37: error: 'size_t' is not a member of 'std' : public integral_constant<std::size_t, __alignof__(_Tp)> { }; ^~~~~~ /usr/include/c++/7/type_traits:1464:37: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_traits:1464:61: error: template argument 1 is invalid : public integral_constant<std::size_t, __alignof__(_Tp)> { }; ^ /usr/include/c++/7/type_traits:1464:61: note: invalid template non-type parameter /usr/include/c++/7/type_traits:1469:37: error: 'size_t' is not a member of 'std' : public integral_constant<std::size_t, 0> { }; ^~~~~~ /usr/include/c++/7/type_traits:1469:37: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_traits:1469:37: error: 'size_t' is not a member of 'std' : public integral_constant<std::size_t, 0> { }; ^~~~~~ /usr/include/c++/7/type_traits:1469:37: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from glo.cpp:2: /usr/include/c++/7/type_t