Submission #19453444
Source Code Expand
Copy
#include<bits/stdc++.h> #define print(x) cout << (#x) << ": " << (x) << endl #define p1d(x) cout << (#x) << ": ["; for(auto& zz: x) cout << zz << " "; cout << "]\n" #define p2d(x) cout << (#x) << ": \n["; for(auto& vec: x) {for(auto& v: vec) cout << v << " "; cout << ",\n";} #define p2s(x) cout << (#x) << ": ["; for(auto& vec: x) {cout << vec << ",\n";} #define pb push_back #define endl "\n" // __builtin_popcount typedef long long ll; using namespace std; int static fast = [](){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }(); // freopen("input.txt", "r", stdin); int main() { ll A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F; // (Cz + Dw)/(100Ax + 100By + Cz + Dw) < E / (100+E) // 100Ax + 100By + Cz + Dw) <= F auto valid = [&] (int x, int y, int z, int w) -> bool { return (C*z+D*w) * (100+E) <= E * (100*A*x + 100*B*y + C*z+D*w); }; // return 100Ax + 100By + Cz + Dw, (Cz + Dw) int total_mass = 0; int sugar_mass = 0; double cur_mx = -1.0; for(int x = 0; x*100*A <= F; x++) { int remain_x = F - x*100*A; for(int y = 0; y*100*B <= remain_x; y++) { int remain_y = remain_x - y*100*B; for(int z = 0; z*C <= remain_y; z++) { int remain_z = remain_y - z*C; for(int w = 0; w*D <= remain_z; w++) { // print(x); // print(y); // print(z); // print(w); if (valid(x, y, z, w)) { int mass = (100*A*x + 100*B*y + C*z+D*w); int s_mass = C*z+D*w; if (mass > 0 && double(s_mass)/double(mass) > cur_mx) { // if (mass > 0 && s_mass > cur_mx * mass) { cur_mx = double(s_mass)/double(mass); total_mass = mass; sugar_mass = s_mass; } } } } } } cout << total_mass << " " << sugar_mass << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Sugar Water |
User | ceass20xx |
Language | C++ (GCC 9.2.1) |
Score | 300 |
Code Size | 2188 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 3604 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 5 ms | 3540 KB |
02.txt | AC | 2 ms | 3496 KB |
03.txt | AC | 2 ms | 3528 KB |
04.txt | AC | 2 ms | 3500 KB |
05.txt | AC | 2 ms | 3516 KB |
06.txt | AC | 7 ms | 3500 KB |
07.txt | AC | 2 ms | 3452 KB |
08.txt | AC | 2 ms | 3544 KB |
09.txt | AC | 2 ms | 3604 KB |
subtask0_0.txt | AC | 2 ms | 3532 KB |
subtask0_1.txt | AC | 9 ms | 3544 KB |
subtask0_2.txt | AC | 2 ms | 3460 KB |