Submission #868025

# Submission time Handle Problem Language Result Execution time Memory
868025 2023-10-30T08:45:59 Z imarn Money (IZhO17_money) C++14
0 / 100
0 ms 344 KB
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int dp[n];int sz=1;
    dp[0]=1;vector<int>q[n+1];
    q[1].pb(0);
    vector<int>v;v.pb(a[0]);
    for(int i=1;i<n;i++){
        int idx=upper_bound(v.begin(),v.end(),a[i])-v.begin();
        if(idx==sz)v.pb(a[i]),dp[i]=++sz,q[sz].pb(i);
        else v[idx]=a[i],dp[i]=idx+1,q[idx+1].pb(i);
    }int mx=0;
    for(int i=0;i<n;i++)mx=max(mx,(int)q[i].size());
    cout<<mx;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:11:9: warning: variable 'dp' set but not used [-Wunused-but-set-variable]
   11 |     int dp[n];int sz=1;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -