Submission #716106

#TimeUsernameProblemLanguageResultExecution timeMemory
716106BaytoroGlobal Warming (CEOI18_glo)C++17
100 / 100
118 ms8468 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll INF=1e18,mod=1e9+7,N=1e5+5; int n,x; int a[2*N],pref[2*N]; void solve(){ cin>>n>>x; vector<int> vec(n,INF); for(int i=0;i<n;i++){ cin>>a[i]; } int ans=0; for(int i=0;i<n;i++){ int it=lower_bound(all(vec),a[i])-vec.begin(); vec[it]=a[i]; pref[i]=it+1; ans=max(ans,it+1); } vec=vector<int> (n,INF); reverse(a,a+n); for(int i=0;i<n;i++){ int it=lower_bound(all(vec),x-a[i])-vec.begin(); ans=max(ans,pref[n-i-1]+it); it=lower_bound(all(vec),-a[i])-vec.begin(); vec[it]=-a[i]; } cout<<ans; } main(){ //fopn("cbarn"); //ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); } }

Compilation message (stderr)

glo.cpp:42:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main(){
      | ^~~~
glo.cpp: In function 'void fopn(std::string)':
glo.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...