Submission #169987

#TimeUsernameProblemLanguageResultExecution timeMemory
169987mhy908Global Warming (CEOI18_glo)C++14
17 / 100
77 ms5452 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; LL x, arr[200010]; vector<LL> lis, lds; int dplis[200010], dplds[200010], ans; int main() { scanf("%d %lld", &n, &x); for(int i=1; i<=n; i++)scanf("%d", &arr[i]); for(int i=1; i<=n; i++){ auto it=lower_bound(lis.begin(), lis.end(), arr[i]); if(it==lis.end())lis.pb(arr[i]); else *it=arr[i]; dplis[i]=lower_bound(lis.begin(), lis.end(), arr[i+1]+x)-lis.begin(); } ans=dplis[n]; for(int i=n; i>=1; i--){ auto it=lower_bound(lds.begin(), lds.end(), -arr[i]); if(it==lds.end())lds.pb(-arr[i]); else *it=-arr[i]; dplds[i]=lds.size(); } ans=dplds[1]; for(int i=1; i<n; i++){ ans=max(ans, dplis[i]+dplds[i+1]); } printf("%d", ans); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:19:47: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'LL* {aka long long int*}' [-Wformat=]
     for(int i=1; i<=n; i++)scanf("%d", &arr[i]);
                                        ~~~~~~~^
glo.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld", &n, &x);
     ~~~~~^~~~~~~~~~~~~~~~~~~
glo.cpp:19:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)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...