Submission #1086275

#TimeUsernameProblemLanguageResultExecution timeMemory
1086275dwuyCloud Computing (CEOI18_clo)C++14
100 / 100
544 ms2384 KiB
/** - dwuy -       />  フ       |  _  _|       /`ミ _x ノ      /      |     /  ヽ   ?  / ̄|   | | |  | ( ̄ヽ__ヽ_)_)  \二つ **/ #include <bits/stdc++.h> #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL) #define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout) #define fi first #define se second #define endl "\n" #define len(s) (int)((s).size()) #define MASK(k)(1LL<<(k)) #define TASK "test" #define int long long using namespace std; typedef tuple<int, int, int> tpiii; typedef pair<double, double> pdd; typedef pair<int, int> pii; typedef long long ll; const long long OO = 1e18; const int MOD = 1e9 + 7; const int INF = 1e9; const int MX = 4005; struct Deptrai{ int quant, rate, cost; Deptrai(): quant(0), rate(0), cost(0) {} void read(){ cin >> quant >> rate >> cost; } void get(int &a, int &b, int &c){ a = quant; b = rate; c = cost; } bool operator < (const Deptrai &other){ return rate != other.rate? rate > other.rate : quant > other.quant; } }; int n, m; Deptrai dwuy[MX]; int f[MX*50]; void nhap(){ cin >> n; for(int i=1; i<=n; i++){ dwuy[i].read(); dwuy[i].cost = -dwuy[i].cost; } cin >> m; for(int i=n+1; i<=n+m; i++){ dwuy[i].read(); dwuy[i].quant = -dwuy[i].quant; } n += m; } void solve(){ sort(dwuy + 1, dwuy + 1 + n); memset(f, -0x3f, sizeof f); f[0] = 0; for(int i=1; i<=n; i++){ int quant, rate, cost; dwuy[i].get(quant, rate, cost); if(quant < 0) for(int i=0; i-quant<MX*50; i++){ f[i] = max(f[i], f[i - quant] + cost); } if(quant > 0) for(int i=MX*50-1; i>=quant; i--){ f[i] = max(f[i], f[i - quant] + cost); } } int ans = 0; for(int i=0; i<MX*50; i++) ans = max(ans, f[i]); cout << ans; } int32_t main(){ fastIO; //file(TASK); nhap(); solve(); return 0; }
#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...