We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
우체국
### 풀이 언어 - python/java ### 코드 ```python/java ``` ### 핵심 로직 혹은 자료구조 - ### 시간 복잡도 - O( )
The text was updated successfully, but these errors were encountered:
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); Town[] towns = new Town[n]; long count = 0; StringTokenizer st; for (int i = 0; i < n; i++) { st = new StringTokenizer(br.readLine()); towns[i] = new Town(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())); count += towns[i].a; } Arrays.sort(towns); long mid = (count + 1) >> 1; long sum = 0; for (int i = 0; i < n ; i++) { sum += towns[i].a; if(sum >= mid) { System.out.println(towns[i].x); break; } } } private static class Town implements Comparable<Town>{ long x; long a; public Town(long x, long a) { this.x = x; this.a = a; } @Override public int compareTo(Town o) { return (int) (this.x - o.x); } } }
Sorry, something went wrong.
CMSSKKK
No branches or pull requests
TITLE
우체국
LINK
📷 Screenshots
댓글 양식
The text was updated successfully, but these errors were encountered: