Submission #920247

# Submission time Handle Problem Language Result Execution time Memory
920247 2024-02-02T10:37:50 Z prefixorsuuffiixx Global Warming (CEOI18_glo) C++14
0 / 100
121 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
// #pragma GCC       optimize("Ofast, unroll-loo    ps, O3")

#define int long long     
#define all(x) x.begin(),x.end()
#define pb push_back 
#define S second
#define F first 
typedef pair<int, int> pii;

const int maxx = 1e6+5;
const int mxx = 2000+15;
const int Log = 20; 
const long long inf = 1e18;
const long long Mod = 1000000007;
const int SQ = 335;
const int p = 211;



int n , c[maxx] , f[maxx] , v[maxx] , C[maxx] , F[maxx] , V[maxx] , m , buy[50*maxx][2] , sell[50*maxx][2];



void solve()
{     

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>c[i]>>f[i]>>v[i];
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>C[i]>>F[i]>>V[i];
    }
    for(int i = 0 ; i <=  50*n ; i++){
        buy[i][0] = inf;
        buy[i][1] = inf;
        sell[i][0] = -inf;
        sell[i][1] = -inf;
    }
    buy[0][0]=0;
    for(int j=0;j<n;j++)
    {
        for(int i=0 ; i <= 50*n ; i++)
            if(buy[i][0]!=inf)
                buy[i+c[j]][1]=min(buy[i+c[j]][1],buy[i][0]+v[j]);  
        for(int i=0;i<=(50*n);i++)
            buy[i][0]=min(buy[i][0],buy[i][1]);
    }
    
    sell[0][0]=0;
    for(int j=0;j<m;j++)
    {
        for(int i=0;i<= 50*m ;i++)
            if(sell[i][0] != -inf)
                sell[i+C[j]][1] = max ( sell[i+C[j]][1], sell[i][0]+V[j]);  
        for(int i=0;i<=(50*n);i++)
            sell[i][0]=max(sell[i][0],sell[i][1]);
    }
    int ans=0;
    int mx=-inf-1;
    for(int i=0;i<= 50*n ;i++)
    {
    	mx=max(mx,sell[i][0]);
    	// if(i<=11)
    	// {
    		// cout<<mx<<' '<<buy[i][0]<<endl;
    	// }
        ans=max(ans,mx-buy[i][0]);
    }
    cout<<ans<<'\n';
}


signed main()
{   
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin>>t;

    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 69 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 76 ms 127060 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 121 ms 251216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -