답안 #710569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710569 2023-03-15T11:13:43 Z groshi Teams (CEOI11_tea) C++17
100 / 100
371 ms 86552 KB
#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

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++)
      |                     ~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 14 ms 23820 KB Output is correct
3 Correct 13 ms 23692 KB Output is correct
4 Correct 13 ms 23760 KB Output is correct
5 Correct 15 ms 23700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23736 KB Output is correct
2 Correct 13 ms 23712 KB Output is correct
3 Correct 13 ms 23812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 13 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 23980 KB Output is correct
2 Correct 14 ms 23976 KB Output is correct
3 Correct 13 ms 23892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23892 KB Output is correct
2 Correct 14 ms 23952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 26124 KB Output is correct
2 Correct 33 ms 25928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 26368 KB Output is correct
2 Correct 31 ms 25784 KB Output is correct
3 Correct 38 ms 26368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 43816 KB Output is correct
2 Correct 196 ms 44832 KB Output is correct
3 Correct 217 ms 44608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 274 ms 49564 KB Output is correct
2 Correct 371 ms 86552 KB Output is correct
3 Correct 260 ms 51500 KB Output is correct
4 Correct 252 ms 46488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 294 ms 51880 KB Output is correct
2 Correct 216 ms 52904 KB Output is correct
3 Correct 251 ms 49708 KB Output is correct
4 Correct 281 ms 49248 KB Output is correct