Submission #74080

#TimeUsernameProblemLanguageResultExecution timeMemory
74080haitunCloud Computing (CEOI18_clo)C++14
18 / 100
923 ms2264 KiB
#include <bits/stdc++.h> //#include "functions.h" #define FOR(x,y) for(int x = 0; x < y; x++) #define ALLR(x) x.begin(),x.end() #define con continue #define ll long long #define LINF LLONG_MAX #define INF INT_MAX #define pii pair<int,int> #define vi vector <int> #define pb push_back #define F first #define S second #define len(x) x.length() #define sz(x) x.size() #define SEE(v) for(auto x : v) cout << x << " "; cout << endl; #define buy 1 #define sell 0 #define yes 1 #define no 0 using namespace std; int main(){ //freopen("test.txt","r",stdin); //vector pair<pii, pii> com; vector <pair<pair<int,int>, pair<int, int> > > com; int n; cin >> n; FOR(j, n) { int x,y,z; cin >> x >> y >> z; com.pb(make_pair(make_pair(y, 1), make_pair(x, z))); } int m; cin >> m; FOR(j, m) { int x,y,z; cin >> x >> y >> z; com.pb(make_pair(make_pair(y, 0), make_pair(x, z))); } sort(ALLR(com)); reverse(ALLR(com)); int dp[2][111115]; //dp[i][j], 0 is previous situation, j is cores lefted FOR(j, 111115) dp[0][j] = dp[1][j] = -INF; dp[1][0] = 0; //1 is "previous" && we start with 0 core FOR(j, n + m) { int cur = j % 2, prev = ((cur == 0) ? 1 : 0); //prev points to previous situation //cout << cur << " " << prev << endl; int f = com[j].F.F, type = com[j].F.S, core = com[j].S.F, cost = com[j].S.S; //cout << f << " " << type << " " << core << " " << cost << endl; //set current situation to -INF //check all posibble # of cores //if have cores, then process buy || sell FOR(k, 111111) dp[cur][k] = -INF; FOR(k, 111111) { if(dp[prev][k] > -INF) { int p = dp[prev][k]; if(dp[cur][k] < p) dp[cur][k] = p; if(type == buy) { if(dp[cur][k + core] < p - cost) dp[cur][k + core] = p - cost; } else// if(type == sell) { if(k >= core) if(dp[cur][k - core] < p + cost) dp[cur][k - core] = p + cost; } } } } int ans = 0; FOR(j, 111111) { ans = max(ans, dp[(n + m - 1) % 2][j]); } cout << ans; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:57:7: warning: unused variable 'f' [-Wunused-variable]
   int f = com[j].F.F, type = com[j].F.S, core = com[j].S.F, cost = com[j].S.S;
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...