Submission #538361

#TimeUsernameProblemLanguageResultExecution timeMemory
538361terrasphereGlobal Warming (CEOI18_glo)C++17
38 / 100
2087 ms4552 KiB
#include <bits/stdc++.h> using namespace std; long long n,x; long long LIS(vector<long long> vec) { vector<long long> lis; for(int i=0;i<n;i++) { if(lis.empty() || lis.back()<vec[i]) lis.push_back(vec[i]); else lis[lower_bound(lis.begin(),lis.end(),vec[i])-lis.begin()]=vec[i]; } return lis.size(); } int main() { scanf("%lld%lld",&n,&x); vector<long long> v; v.resize(n); for(int i=0;i<n;i++) scanf("%lld",&v[i]); long long answer=0; if(x==0) { printf("%lld\n",LIS(v)); return 0; } for(int i=0;i<n;i++) { v[i]-=x; answer=max(answer,LIS(v)); } for(int i=0;i<n;i++) v[i]+=x; for(int i=n-1;i>0;i--) { v[i]+=x; answer=max(answer,LIS(v)); } printf("%lld\n",answer); return 0; }

Compilation message (stderr)

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