Submission #710569

#TimeUsernameProblemLanguageResultExecution timeMemory
710569groshiTeams (CEOI11_tea)C++17
100 / 100
371 ms86552 KiB
#include<bits/stdc++.h> using namespace std; vector<int> wypisz[1000006]; int dp[1000006]; priority_queue<pair<int,int> > kolejka; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; vector<pair<int,int> > Q; for(int i=1;i<=n;i++) { int x; cin>>x; Q.push_back({x,i}); } sort(Q.begin(),Q.end()); for(int i=0;i<Q.size()-1;i++) { if(Q[i].first>i+1) dp[i]=dp[i-1]; else dp[i]=max(dp[i-1],dp[i-Q[i].first]+1); } dp[n-1]=dp[n-1-Q.back().first]+1; int ktora=1; for(int i=Q.size()-1;i>=0;i--) { int ile=Q[i].first; if(i+1<ile || (dp[i-1]>dp[i-Q[i].first]+1 && i!=Q.size()-1)) { pair<int,int> para=kolejka.top(); kolejka.pop(); wypisz[para.second].push_back(Q[i].second); kolejka.push({-wypisz[para.second].size(),para.second}); } else{ for(int j=i;j>i-ile;j--) wypisz[ktora].push_back(Q[j].second); kolejka.push({-wypisz[ktora].size(),ktora}); i-=ile; i++; ktora++; } } cout<<ktora-1<<"\n"; for(int i=1;i<ktora;i++) { cout<<wypisz[i].size()<<" "; for(int j=0;j<wypisz[i].size();j++) cout<<wypisz[i][j]<<" "; cout<<"\n"; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int32_t main()':
tea.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0;i<Q.size()-1;i++)
      |                 ~^~~~~~~~~~~
tea.cpp:33:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(i+1<ile || (dp[i-1]>dp[i-Q[i].first]+1 && i!=Q.size()-1))
      |                                                      ~^~~~~~~~~~~~
tea.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int j=0;j<wypisz[i].size();j++)
      |                     ~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...