Submission #515730

# Submission time Handle Problem Language Result Execution time Memory
515730 2022-01-19T14:45:48 Z _Monkey_ Financial Report (JOI21_financial) C++17
0 / 100
52 ms 1496 KB
// Song Đồng Gia Phúc

/*
 *      ʕ•ᴥ•ʔ
 *  [Penguin_024]
 *       U U
 */

#include<bits/stdc++.h>
using namespace std;

#define el '\n'
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define double double
#define fi first
#define se second
#define cico(A) freopen(A".INP","r",stdin); freopen(A".OUT","w",stdout);
template<typename x,typename y> void amin(x &a,y b){if(b<a) a=b;}
template<typename x,typename y> void amax(x &a,y b){if(b>a) a=b;}
const int maxn=3e5+7,maxq=19*1e4+7;
const string yes="YES\n",no="NO\n";

int n,d,a[maxn];
int ans,res;

/////// SUB 4
void sub4(){
    vector<int> f;
    ans = 0;
    for(int i=n;i>0;--i){
        while( !f.empty() && a[i]>=f.back() ) f.pop_back();
        f.push_back(a[i]);
        amax( ans , f.size() );
    }
    cout << ans;
}

/////// SUB 1
void quaylui(int id,int maxi,int sum,int kc){
    if(kc>=d) return;
    if(id==n+1){
        amax(ans,sum);
        return;
    }
    quaylui( id+1 , max(maxi,a[id]) , sum + (a[id]>maxi) , 0 );
    quaylui( id+1 , maxi , sum , kc + (sum>0) );
}

void sub1(){
    ans = 0;
    quaylui(1,-1,0,0);
    cout << ans;
}

/////// SUB 5
void sub5(){
    vector<int> f(1,-1);
    for(int i=1;i<n;++i){
        if( a[i]>f.back() ){
            f.push_back(a[i]);
        } else {
            res = lower_bound( f.begin() , f.end() , a[i] ) - f.begin();
            f[res] = a[i];
        }
    }
    if( a[n]>f.back() ){
        ans = f.size();
    } else {
        ans = lower_bound( f.begin() , f.end() , a[n] ) - f.begin();
    }
    cout << ans;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> d;
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }

//    // sub 4
//    if(d==1){
//        sub4();
//        return 0;
//    }
//
//    // sub 1
//    if(n<=20){
//        sub1();
//        return 0;
//    }

    // sub 5
    if(d==n){
        sub5();
        return 0;
    }

    return 0;
}

Compilation message

Main.cpp: In instantiation of 'void amax(x&, y) [with x = int; y = long unsigned int]':
Main.cpp:35:30:   required from here
Main.cpp:21:57: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'int' [-Wsign-compare]
   21 | template<typename x,typename y> void amax(x &a,y b){if(b>a) a=b;}
      |                                                        ~^~
# 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 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1496 KB Output is correct
2 Incorrect 52 ms 1376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -