# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710569 | groshi | Teams (CEOI11_tea) | C++17 | 371 ms | 86552 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |