Submission #491662

# Submission time Handle Problem Language Result Execution time Memory
491662 2021-12-03T18:27:40 Z Bench0310 Teams (CEOI11_tea) C++17
80 / 100
435 ms 27996 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<array<int,2>> a(n+1,{0,0});
    for(int i=1;i<=n;i++)
    {
        cin >> a[i][0];
        a[i][1]=i;
    }
    sort(a.begin(),a.end());
    vector<int> p(n+1,0);
    auto go=[&](int lim)->int
    {
        vector<int> dp(n+1,-1);
        dp[0]=0;
        vector<int> prv(n+1,0);
        int mx=0;
        for(int i=1;i<=n;i++)
        {
            prv[i]=prv[i-1];
            if(a[i][0]>i) continue;
            int j=prv[i-a[i][0]];
            if(i-lim<=j&&((i<n&&dp[j]+1>=mx)||i==n))
            {
                dp[i]=dp[j]+1;
                prv[i]=i;
                p[i]=j;
            }
        }
        return dp[n];
    };
    int cnt=go(n);
    int l=0,r=n;
    while(l<r-1)
    {
        int m=(l+r)/2;
        if(go(m)==cnt) r=m;
        else l=m;
    }
    cout << cnt << "\n";
    go(r);
    int idx=n;
    while(idx>=1)
    {
        cout << idx-p[idx] << " ";
        for(int i=p[idx]+1;i<=idx;i++) cout << a[i][1] << " \n"[i==idx];
        idx=p[idx];
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 452 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1996 KB Output is correct
2 Correct 29 ms 2084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2188 KB Output is correct
2 Correct 27 ms 1928 KB Output is correct
3 Correct 31 ms 2240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 319 ms 15148 KB Output is correct
2 Correct 304 ms 17212 KB Output is correct
3 Correct 291 ms 19436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 414 ms 20088 KB Output is correct
2 Correct 378 ms 23068 KB Output is correct
3 Correct 395 ms 22912 KB Output is correct
4 Correct 428 ms 22436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 387 ms 20092 KB Output is correct
2 Correct 330 ms 27996 KB Output is correct
3 Correct 407 ms 23960 KB Output is correct
4 Correct 435 ms 25652 KB Output is correct