Skip to content

Commit

Permalink
CT_277
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-Good committed Oct 10, 2024
1 parent eae7155 commit da51cf8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions BOJ/Java/src/B2/Boj_9070_장보기.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package B2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class Boj_9070_장보기 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();

int T = Integer.parseInt(br.readLine());
for (int t = 0; t < T; t++) {
int N = Integer.parseInt(br.readLine());
int cost = 0;
double WpC = 0.0;

for (int i = 0; i < N; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
double W = Double.parseDouble(st.nextToken());
double C = Double.parseDouble(st.nextToken());

if (WpC < W / C || (WpC == W / C && cost > C)) {
WpC = W / C;
cost = (int) C;
}
}

sb.append(cost).append('\n');
}

bw.write(sb.toString());
bw.flush();
}
}

0 comments on commit da51cf8

Please sign in to comment.