Submission #388494

#TimeUsernameProblemLanguageResultExecution timeMemory
388494IwanttobreakfreeGlobal Warming (CEOI18_glo)C++17
0 / 100
236 ms262148 KiB
#include <iostream> #include <vector> #include <set> using namespace std; int main(){ int n,x,maxi=0,maxi2; cin>>n>>x; vector<int>list(n); for(int i=0;i<n;i++){ cin>>list[i]; } vector<vector<pair<int,set<int> > > >DP(n,vector<pair<int,set<int> > >(n)); vector<bool> visto(n,false); pair<int,set<int> > maximo; for(int i=0;i<n;i++){ if(visto[i])continue; DP[i][i].first=list[i]; DP[i][i].second.insert(i); maximo=DP[i][i]; for(int j=i+1;j<n;j++){ if(visto[j])continue; for(int q=i;q<j;q++){ if(list[j]>DP[i][q].first&&DP[i][q].second.size()+1>DP[i][j].second.size()){ DP[i][j]=DP[i][q]; DP[i][j].first=list[j]; DP[i][j].second.insert(j); if(DP[i][j].second.size()>maximo.second.size())maximo=DP[i][j]; } } if(DP[i][j].first==0)DP[i][j]=maximo; } int t=maximo.second.size(); if(t>maxi)maxi=t; else if(t>maxi2)maxi2=t; for(auto it=maximo.second.begin();it!=maximo.second.end();it++){ visto[*it]=true; } } cout<<maxi+maxi2; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:39:13: warning: 'maxi2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |  cout<<maxi+maxi2;
      |             ^~~~~
#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...