답안 #497355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497355 2021-12-23T03:40:48 Z SirCovidThe19th Teams (CEOI11_tea) C++17
80 / 100
420 ms 32448 KB
#include <bits/stdc++.h>
using namespace std; 

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); 
    int n; cin >> n; pair<int, int> A[n + 1]; 
    for (int i = 1; i <= n; i++) cin >> A[i].first, A[i].second = i;
    sort(A + 1, A + n + 1);

    auto maxTeams = [&](int mxsz, bool get){
        int dp[n + 1], sz[n + 1], lft[n + 1]; 
        memset(dp, -0x3f, sizeof(dp)); dp[0] = lft[0] = 0;

        for (int i = 1; i <= n; i++){
            int l = max(i - mxsz, 0), r = i - A[i].first;
            if (r >= 0 and l <= lft[r]){
                dp[i] = dp[lft[r]] + 1; 
                sz[i] = i - lft[r];
            }
            lft[i] = (dp[i] >= 0) ? i : lft[i - 1];
        }
        if (get){
            cout<<dp[n]<<"\n";
            for (int pos = n; pos; pos -= sz[pos]){
                cout<<sz[pos]<<" ";
                for (int i = pos; i > pos - sz[pos]; i--) cout<<A[i].second<<" ";
                cout<<"\n";
            }
        }
        return dp[n];
    };
    int L = 1, H = n, mx = maxTeams(1e9, 0);
    while (L < H){
        int M = (L + H) / 2;
        (maxTeams(M, 0) == mx) ? H = M : L = M + 1;
    }
    maxTeams(H, 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 452 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 2580 KB Output is correct
2 Correct 31 ms 2500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 2880 KB Output is correct
2 Correct 24 ms 2388 KB Output is correct
3 Correct 31 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 278 ms 20864 KB Output is correct
2 Correct 280 ms 22452 KB Output is correct
3 Correct 284 ms 24584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 27016 KB Output is correct
2 Correct 420 ms 31788 KB Output is correct
3 Correct 354 ms 29740 KB Output is correct
4 Correct 324 ms 28344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 324 ms 26660 KB Output is correct
2 Correct 277 ms 28268 KB Output is correct
3 Correct 383 ms 28208 KB Output is correct
4 Correct 375 ms 32448 KB Output is correct