Submission #170004

#TimeUsernameProblemLanguageResultExecution timeMemory
170004mhy908Global Warming (CEOI18_glo)C++14
0 / 100
2056 ms207000 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; const LL llinf=9000000000000000000; int n; LL x, arr[200010]; vector<LL> lis, lds; int dplis[200010], dplds[200010], ans; LL minlds[200010]; pair<int, LL> change[200010]; int main() { scanf("%d %lld", &n, &x); for(int i=1; i<=n; i++)scanf("%lld", &arr[i]); for(int i=1; i<=n; i++){ auto it=lower_bound(lis.begin(), lis.end(), arr[i]); change[i]=mp(it-lis.begin(), it==lis.end()?llinf:*it); if(it==lis.end())lis.pb(arr[i]); else *it=min(arr[i], *it); dplis[i]=lower_bound(lis.begin(), lis.end(), minlds[i+1]+x)-lis.begin(); ans=max(ans, dplis[i]+dplds[i+1]); } ans=dplis[n]; arr[0]=-llinf; for(int i=n; i>=1; i--){ lis[change[i].F]=change[i].S; puts("LIS : "); for(int j=0; j<lis.size(); j++)printf("%lld ", lis[j]); puts(""); auto it=lower_bound(lds.begin(), lds.end(), -arr[i]); int temp1=it-lds.begin()+1; if(it==lds.end())lds.pb(-arr[i]); else *it=-arr[i]; int temp2=lower_bound(lis.begin(), lis.end(), arr[i]+x)-lis.begin(); ans=max(ans, temp1+temp2); } printf("%d", ans); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0; j<lis.size(); j++)printf("%lld ", lis[j]);
                      ~^~~~~~~~~~~
glo.cpp:17: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:18: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("%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...