Submission #895556

# Submission time Handle Problem Language Result Execution time Memory
895556 2023-12-30T08:59:57 Z presko Schools (IZhO13_school) C++14
10 / 100
45 ms 20304 KB
#include<iostream>
#include<bits/stdc++.h>
#define MAXN 300010
using namespace std;
long long dp[MAXN][3];//long long
pair<int,int> state[MAXN][3];
pair<int,int> city[MAXN];
//vector<pair<pair<int,int>,int>> order;
int main()
{
    int n,m,s;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>s;
    state[0][0]={m,s};
    state[0][1]={m,s};
    state[0][2]={m,s};
    for(int i=1;i<=n;i++)
    {
        cin>>city[i].first>>city[i].second;
        state[i][0]={m,s};
        state[i][1]={m,s};
        state[i][2]={m,s};
        //order.push_back({city[i],i});
    }
    //sort(order.begin(),order.end(),greater<pair<pair<int,int>,int>>());
    for(int i=1;i<=n;i++)
    {
        int mus=city[i].first;
        int sp=city[i].second;

        for(int j=0;j<3;j++)
        {
            if(dp[i-1][j]>dp[i][0])
            {
                dp[i][0]=dp[i-1][j];
                state[i][0]=state[i-1][j];
            }
            if(dp[i-1][j]+mus>dp[i][1] && state[i-1][j].first>0)
            {
                dp[i][1]=dp[i-1][j]+mus;
                state[i][1]=state[i-1][j];
                state[i][1].first--;
            }
            if(dp[i-1][j]+sp>dp[i][2] && state[i-1][j].second>0)
            {
                dp[i][2]=dp[i-1][j]+sp;
                state[i][2]=state[i-1][j];
                state[i][2].second--;
            }
        }
    }
    long long ans=0;
    for(int i=0;i<3;i++)
    {
        if(dp[n][i]>ans)ans=dp[n][i];
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Incorrect 1 ms 2392 KB Output isn't correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Incorrect 1 ms 2648 KB Output isn't correct
9 Incorrect 1 ms 2652 KB Output isn't correct
10 Incorrect 2 ms 2648 KB Output isn't correct
11 Incorrect 1 ms 2652 KB Output isn't correct
12 Incorrect 1 ms 2652 KB Output isn't correct
13 Incorrect 5 ms 5896 KB Output isn't correct
14 Incorrect 12 ms 7184 KB Output isn't correct
15 Incorrect 22 ms 12112 KB Output isn't correct
16 Incorrect 24 ms 14928 KB Output isn't correct
17 Incorrect 34 ms 16516 KB Output isn't correct
18 Incorrect 32 ms 17132 KB Output isn't correct
19 Incorrect 40 ms 18928 KB Output isn't correct
20 Incorrect 45 ms 20304 KB Output isn't correct