Submission #170006

#TimeUsernameProblemLanguageResultExecution timeMemory
170006mhy908Global Warming (CEOI18_glo)C++14
100 / 100
89 ms5880 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define F first #define S second using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; const LL llinf=9000000000000000000; const int inf=2000000000; int n, x; int lis[200010], lds[200010], ans, arr[200010]; pair<int, int> change[200010]; int main() { scanf("%d %d", &n, &x); for(int i=1; i<=n; i++){ scanf("%d", &arr[i]); lis[i]=inf; } for(int i=1; i<=n; i++){ int it=lower_bound(lis+1, lis+n+1, arr[i])-lis; change[i]=mp(it, lis[it]); lis[it]=arr[i]; ans=max(ans, it); } for(int i=n; i>=1; i--){ int it=lower_bound(lds+1, lds+n+1, -arr[i])-lds; lds[it]=-arr[i]; lis[change[i].F]=change[i].S; int jt=lower_bound(lis+1, lis+n+1, arr[i]+x)-lis-1; ans=max(ans, it+jt); } printf("%d", ans); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &x);
     ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &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...