Submission #144671

#TimeUsernameProblemLanguageResultExecution timeMemory
144671nekiGlobal Warming (CEOI18_glo)C++14
100 / 100
86 ms8596 KiB
#include <bits/stdc++.h> #define loop(i, a, b) for(int i=a;i<b;i++) #define maxn 201000 using namespace std; typedef long long ll; ll arr[maxn], fo[maxn], ba[maxn], temp[maxn]; int main(){ int n, x;cin >> n >> x; x=abs(x); loop(i, 0, n) scanf("%lld", &arr[i]); loop(i, 0, maxn) temp[i]=LLONG_MAX;temp[0]=LLONG_MIN; loop(i, 0, n) fo[i]=lower_bound(temp, temp+n, arr[i]+x)-temp, *lower_bound(temp, temp+n, arr[i])=arr[i]; loop(i, 0, maxn) temp[i]=LLONG_MAX;temp[0]=LLONG_MIN; for(int i=n-1;i>=0;i--) ba[i]=lower_bound(temp, temp+n, -arr[i])-temp, temp[ba[i]]=-arr[i]; ll ans=1; loop(i, 0, n) ans=max(ans, fo[i]+ba[i]-1); cout << ans; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:2:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define loop(i, a, b) for(int i=a;i<b;i++)
                       ^
glo.cpp:12:5: note: in expansion of macro 'loop'
     loop(i, 0, maxn) temp[i]=LLONG_MAX;temp[0]=LLONG_MIN;
     ^~~~
glo.cpp:12:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     loop(i, 0, maxn) temp[i]=LLONG_MAX;temp[0]=LLONG_MIN;
                                        ^~~~
glo.cpp:2:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define loop(i, a, b) for(int i=a;i<b;i++)
                       ^
glo.cpp:14:5: note: in expansion of macro 'loop'
     loop(i, 0, maxn) temp[i]=LLONG_MAX;temp[0]=LLONG_MIN;
     ^~~~
glo.cpp:14:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     loop(i, 0, maxn) temp[i]=LLONG_MAX;temp[0]=LLONG_MIN;
                                        ^~~~
glo.cpp:11:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     loop(i, 0, n) scanf("%lld", &arr[i]);
                   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...