Submission #264551

# Submission time Handle Problem Language Result Execution time Memory
264551 2020-08-14T07:37:44 Z 반딧불(#5094) Teams (CEOI11_tea) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
pair<int, int> arr[10002];
int DP[10002], DP2[10002] = {-1e9};
int track[10002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d", &x);
        arr[i] = {x, i};
    }

    sort(arr+1, arr+n+1);

    for(int i=1; i<=n; i++){
        for(int j=0; j<=i-arr[i].first; j++){
            if(DP[i] < DP[j]+1 || (DP[i] == DP[j]+1 && DP2[i] > max(DP2[j], i-j))){
                DP[i] = DP[j]+1, DP2[i] = max(DP2[j], i-j);
                track[i] = j;
            }
        }
    }

    printf("%d\n", DP[n]);
    while(n){
        printf("%d ", n - track[n]);
        for(int i=track[n]+1; i<=n; i++) printf("%d ", arr[i].second);
        puts("");
        n = track[n];
    }
}

Compilation message

tea.cpp:9:34: error: narrowing conversion of '-1.0e+9' from 'double' to 'int' [-Wnarrowing]
    9 | int DP[10002], DP2[10002] = {-1e9};
      |                                  ^
tea.cpp: In function 'int main()':
tea.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tea.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~