답안 #898306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898306 2024-01-04T13:24:18 Z Newtech66 Teams (CEOI11_tea) C++17
0 / 100
213 ms 37708 KB
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
#define endl "\n"
const lol mod1=1e9+7,mod2=998244353,mod3=100000000000000003,hashpr=31;
const lol inf=9e18+8;
const double eps=1e-12;
const double PI=acos(-1.0);
const int N=1e5+5;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using ordered_set_type=lol;
typedef tree<ordered_set_type,null_type,less<ordered_set_type>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int _=1;
//cin>>_;
while(_--)
{
    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(a.begin(),a.end());
    //dp[i]=1+max(dp[j]) st j<=i-a[i]
    vector<int> dp(n+1,-1),dpmx(n+1,-1),dpargmx(n+1,-1),prev(n+1,-1);
    dp[0]=0;
    dpmx[0]=0;
    dpargmx[0]=0;
    prev[0]=-1;
    for(int i=1;i<=n;i++){
        int j=i-a[i-1].first;
        if(j>=0){
            dp[i]=1+dpmx[j];
            prev[i]=dpargmx[j];
        }
        if(dp[i]>=dpmx[i-1]){
            dpmx[i]=dp[i];
            dpargmx[i]=i;
        }else{
            dpmx[i]=dpmx[i-1];
            dpargmx[i]=dpargmx[i-1];
        }
    }
    vector<int> v;
    int p=n;
    while(p>0){
        v.push_back(p);
        p=prev[p];
    }
    cout<<dp[n]<<endl;
    v.push_back(0);
    for(auto& e:v)  e--;
    reverse(v.begin(),v.end());
    for(int i=0;i<v.size()-1;i++){
        cout<<v[i+1]-v[i]<<" ";
        for(int j=v[i]+1;j<=v[i+1];j++){
            cout<<a[j].second<<" ";
        }
        cout<<endl;
    }
}
return 0;
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i=0;i<v.size()-1;i++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 520 KB Output is correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 3108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 3416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 153 ms 26884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 210 ms 36528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 213 ms 37708 KB Output isn't correct
2 Halted 0 ms 0 KB -