Skip to content

Commit d90961f

Browse files
authored
[20250607] SWEA / D3 / 공과 상자 / 권혁준
1 parent 9ecca7e commit d90961f

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
```java
2+
import java.util.*;
3+
import java.io.*;
4+
5+
class IOController {
6+
BufferedReader br;
7+
BufferedWriter bw;
8+
StringTokenizer st;
9+
10+
public IOController(){
11+
br = new BufferedReader(new InputStreamReader(System.in));
12+
bw = new BufferedWriter(new OutputStreamWriter(System.out));
13+
st = new StringTokenizer("");
14+
}
15+
16+
void nextLine() throws Exception {
17+
st = new StringTokenizer(br.readLine());
18+
}
19+
20+
String nextToken() throws Exception {
21+
while(!st.hasMoreTokens()) nextLine();
22+
return st.nextToken();
23+
}
24+
25+
int nextInt() throws Exception { return Integer.parseInt(nextToken()); }
26+
long nextLong() throws Exception { return Long.parseLong(nextToken()); }
27+
double nextDouble() throws Exception { return Double.parseDouble(nextToken()); }
28+
29+
void close() throws Exception {
30+
bw.flush();
31+
bw.close();
32+
}
33+
34+
void write(String content) throws Exception {
35+
bw.write(content);
36+
}
37+
38+
}
39+
40+
public class Solution {
41+
42+
static IOController io;
43+
44+
//
45+
46+
static int B, W, X, Y, Z;
47+
48+
public static void main(String[] args) throws Exception {
49+
50+
io = new IOController();
51+
52+
for(int T = io.nextInt();T-->0;solve()) input();
53+
54+
io.close();
55+
56+
}
57+
58+
public static void input() throws Exception {
59+
60+
B = io.nextInt();
61+
W = io.nextInt();
62+
X = io.nextInt();
63+
Y = io.nextInt();
64+
Z = io.nextInt();
65+
66+
}
67+
68+
static void solve() throws Exception {
69+
70+
int res = -(int)1e9;
71+
for(int c=0;c<=Math.min(B,W);c++) {
72+
res = Math.max(res, B*X + W*Y - c*(X+Y) + 2*c*Z);
73+
}
74+
io.write(res + "\n");
75+
76+
}
77+
78+
79+
}
80+
```

0 commit comments

Comments
 (0)