Submission #847548

# Submission time Handle Problem Language Result Execution time Memory
847548 2023-09-09T20:54:10 Z Mr_Ph Financial Report (JOI21_financial) C++14
0 / 100
510 ms 1038376 KB
///Never gonna give you up.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
const ll mod=(ll)1e9+7;
const ll mod1=998244353;
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
#define int long long
int n,d;
vi arr;
int dp[402][402][402];
int ans(int idx,int prv,int prv1)
{
    if(idx==n)
        return 0;
    if(dp[idx][prv][prv1]!=-1)
        return dp[idx][prv][prv1];
    int e=0;
    if(arr[idx]<arr[prv])
        e=max(ans(idx+1,prv,idx),e);
    if(arr[idx]>=arr[prv])
        e=max(ans(idx+1,idx,idx)+1-(arr[idx]==arr[prv]),e);
    if(idx-prv1<d||prv==n||prv==n)
        e=max(ans(idx+1,prv,prv1),e);
    return dp[idx][prv][prv1]=e;
}
void preprocess() {}
void solve()
{
    cin>>n>>d;
    arr.resize(n);
    ent(arr);
    if(d==n)
    {
        vi ans;
        for(int i=0; i<n; i++)
        {
            int x=lower_bound(all(ans),arr[i])-ans.begin();
            if(x==ans.sz)
                ans.push_back(arr[i]);
            else
                ans[x]=arr[i];
        }
    }
    else
    {
        memset(dp,-1,sizeof dp);
        arr.push_back(-1e9);
        cout<<ans(0,n,n)<<endl;
    }
}
signed main()
{
    // freopen("div7.in","r",stdin);
    //freopen("div7.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    preprocess();
    //bla();
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:18:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
      |                              ~^~~~~~~~~~~
Main.cpp:46:5: note: in expansion of macro 'ent'
   46 |     ent(arr);
      |     ^~~
Main.cpp:53:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             if(x==ans.sz)
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 510 ms 1038376 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -