Submission #57445

# Submission time Handle Problem Language Result Execution time Memory
57445 2018-07-15T04:53:42 Z 노영훈(#1670) Teams (CEOI11_tea) C++11
50 / 100
2500 ms 20132 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=1000010, inf=2e9;

int n;
struct stu {
    int a, idx, cut, cnt, mx;
} S[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>S[i].a; S[i].idx=i;
    }
    sort(S+1, S+n+1, [](stu &a, stu &b){
        return a.a<b.a;
    });

    // deque<node> Q;

    for(int i=1; i<=n; i++){
        int l=0;
        for(int j=i-S[i].a; j>=0; j--){
            if(S[j].cut<0) continue;
            if(S[l].cnt<S[j].cnt || (S[l].cnt==S[j].cnt && max(S[l].mx, i-l)>max(S[j].mx, i-j))) l=j;
        }
        if(i-l>=S[i].a){
            S[i].cut=l, S[i].cnt=S[l].cnt+1, S[i].mx=max(S[l].mx, i-l);
        }
        else S[i].cut=-1;
    }

    vector<vector<int>> ans;
    int now=n;
    while(now>0){
        vector<int> put;
        for(int i=now; i>S[now].cut; i--)
            put.push_back(S[i].idx);
        ans.push_back(put);
        now=S[now].cut;
    }


    cout<<ans.size()<<'\n';
    for(auto &V:ans){
        cout<<V.size()<<' ';
        for(int x:V) cout<<x<<' ';
        cout<<'\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 696 KB Output is correct
2 Correct 3 ms 696 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 696 KB Output is correct
2 Correct 2 ms 696 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 748 KB Output is correct
2 Correct 29 ms 748 KB Output is correct
3 Correct 39 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 780 KB Output is correct
2 Correct 27 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2524 ms 2188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2600 ms 2484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2510 ms 15248 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2544 ms 20108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2538 ms 20132 KB Time limit exceeded
2 Halted 0 ms 0 KB -