Submission #812488

# Submission time Handle Problem Language Result Execution time Memory
812488 2023-08-07T08:56:26 Z vjudge1 Financial Report (JOI21_financial) C++17
0 / 100
5 ms 596 KB

#include <bits/stdc++.h>



using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 400 + 9 , mod = 1e9 + 7;
ll  d[N] = {} , a[N] = {}, dp[N][N] ,  b[N] , c[5009][5009] = {} , tree[2 * N];




void solve(){
    ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
    cin>>n>>k;
    set<int>st;
    for(i = 1; i <= n; i++){
        cin>>a[i];
        st.insert(a[i]);
    }
    map<int,int>mp;
    vector<int>v;
    for(auto it : st)
        mp[it] = ++s , v.pb(s);
    for(i = 1; i <= n; i++){
        a[i] = mp[a[i]];
        //cout<<a[i]<<"\n";
    }
    for(i = 1; i <= n; i++){
        //for(auto to : v)
           // if(to >= a[i]){
           // if(i == 3)
           //     cout<<to<<"\n";
           // dp[i][to] = 1;
           // }
           for(j = a[i]; j  <= s; j++)
            dp[i][j] = 1;
        z = i - k;
        if(z <= 0)
            z = 1;
        for(j = z; j <= i; j++)
            for(x = a[i] ; x <= s; x++){
                for(y = 1; y <= x; y++){
                dp[i][x] = max(dp[j][y] + (y < a[i]), dp[i][x]);
                }
                if(i == n)
                    mx = max(mx , dp[i][x]);
            }
            }
        //    cout<<a[4]<<" "<<dp[4][3]<<"\n";
    mx  = max(mx , 1ll);
    cout<<mx<<"\n";
    //cout<<1<<"\n";
}

int main(){

     TL;

     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     #endif

int t = 1;
//cin>>t;

while(t--)
     {
     solve();
     }

}
// Author : حسن

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:32:8: warning: unused variable 'q' [-Wunused-variable]
   32 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |        ^
Main.cpp:32:20: warning: unused variable 'm' [-Wunused-variable]
   32 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                    ^
Main.cpp:32:37: warning: unused variable 'f' [-Wunused-variable]
   32 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                     ^
Main.cpp:32:41: warning: unused variable 'l' [-Wunused-variable]
   32 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                         ^
Main.cpp:32:45: warning: unused variable 'r' [-Wunused-variable]
   32 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                             ^
Main.cpp:32:61: warning: unused variable 'mn' [-Wunused-variable]
   32 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                             ^~
Main.cpp: In function 'int main()':
Main.cpp:79:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |      freopen("input.txt", "r", stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:80:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |      freopen("output.txt", "w", stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -