Blue___
코딩배우는 학생🌎
Blue___
전체 방문자
오늘
어제
  • 코딩배우는 학생🧀 (242)
    • Algorithms (145)
      • BOJ[Java] (107)
      • Programmers[Java] (32)
      • Coding_Contest (3)
    • Web (22)
      • .NET Core C# (2)
      • Java (1)
      • Oracle SQL (7)
      • Web-ProJect (3)
      • Error처리 (1)
      • Web지식 (4)
      • Javascript (1)
      • Vue (3)
    • Git (4)
    • Java_beginner(Repl.it) (55)
      • Auto-Graded-Course(AP CS A) (54)
    • 프로젝트 직딩일기 (3)
    • Hanyang_Assignment (0)
    • 이모저모 (4)
      • 잡담 (1)
      • 2021 오픈소스 컨트리뷰터 아카데미 (1)
      • DDD - 6기! (1)
    • 북리뷰 (1)
      • 리팩토링 2판 (1)
      • 클린코드 (0)

블로그 메뉴

  • 🐰GITHUB
  • ☘️포트폴리오
  • 🌸MBC개발_투표 2022
  • 🍭MBC_APP

공지사항

인기 글

태그

  • 프로그래밍
  • repl.it
  • 프로그래머스
  • programmers
  • 자바
  • 코딩배우는 학생
  • Java tutorial
  • 코딩배우는학생
  • Java
  • REPL
  • 레플릿
  • Bakjoon
  • coding
  • 코딩
  • 알고리즘
  • auto-graded course
  • algorithm
  • 백준
  • AP CS A
  • java basic

최근 댓글

최근 글

티스토리

hELLO
Blue___

코딩배우는 학생🌎

[백준/17530번] Buffon(Maratona de Programação SBC 2019)[Java]
Algorithms/BOJ[Java]

[백준/17530번] Buffon(Maratona de Programação SBC 2019)[Java]

2019. 12. 22. 00:53

Problem

The Kingdom of Matchings is governed by a generous commander. The commander’s fame and great qualities are known to all, including neighboring kingdoms. One of his most famous qualities is his good humor, which is nourished daily by a court buffoon, elected annually at the Great Comedy Contest (GCC) of the kingdom. The court buffoon helps to relieve all the tension of the various political meetings the work demands, rejoicing not only the commander but the whole kingdom.

Young Carlos is a great comedian whose dream is to become next season’s buffoon. He has spent the past few months writing new jokes and puns of various kinds, many of which are about his own (tiny) stature. The time has come for the buffoon election and a total of N candidates have registered. Each candidate will have five minutes to perform in front of the audience. After the performances, each citizen of the Kingdom of Matchings may vote for one of the candidates, and the most voted candidate will be elected as court buffoon. If there is a tie between one or more candidates, the one who registered first is elected. Knowing this, young Carlos spent nights in front of the electoral office and ensured that his application was the first to be registered.

After the votes, it remains only to determine the results. The voting machine generates a report with N integers, corresponding to the number of votes for each candidate, ordered in order of registration. Your mission is to determine if young Carlos was elected or not.

Input

The first line of input contains an integer N, (2 ≤ N ≤ 104). The next N lines will contain N positive integers v1, . . . , vN , one on each line, corresponding to the number of votes each candidate received, in order of registration. Since the Kingdom of matchings population is 100,000 people, the total number of votes will not exceed this value, i.e Σvi ≤ 100,000.

Output

Your program must output a single line containing the character ‘S’ if young Carlos is elected as buffoon, or the character ‘N’ otherwise.

 


Solution

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.*;
import javax.swing.text.AbstractDocument.BranchElement;
import java.io.*;
 
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()); //사람수 입력 
        int [] arr=new int[n];
        for(int i=0;i<n;i++) {
            arr[i]=Integer.parseInt(br.readLine());
        }
        int carlos=arr[0];
        boolean sw=false;
        for(int i=1;i<n;i++) {
            if(arr[i]>carlos) {
                sw=true;
            }
        }
        System.out.println(!sw?"S":"N");
    }
}
 
 
 

https://www.acmicpc.net/problem/17530

 

17530번: Buffoon

The first line of input contains an integer N, (2 ≤ N ≤ 104). The next N lines will contain N positive integers v1, . . . , vN , one on each line, corresponding to the number of votes each candidate received, in order of registration. Since the Kingdom of

www.acmicpc.net

 

반응형
저작자표시 (새창열림)

'Algorithms > BOJ[Java]' 카테고리의 다른 글

[백준/10773번] 제로(CCC 2015 Senior Division) [Java]  (0) 2019.12.24
[백준/17173번] 배수들의 합(충남대 3회 생각하는 프로그래밍 대회)[Java]  (0) 2019.12.22
[백준/15740번] A+B - 9 [Java]  (0) 2019.12.22
[백준/5533번] 유니크(JOI 2013)[Java]  (0) 2019.12.22
[백준/15803번] PLAYERJINAH’S BOTTLEGROUNDS (2018 SCCC Programming Contest)[Java]  (0) 2019.12.21
    'Algorithms/BOJ[Java]' 카테고리의 다른 글
    • [백준/10773번] 제로(CCC 2015 Senior Division) [Java]
    • [백준/17173번] 배수들의 합(충남대 3회 생각하는 프로그래밍 대회)[Java]
    • [백준/15740번] A+B - 9 [Java]
    • [백준/5533번] 유니크(JOI 2013)[Java]
    Blue___
    Blue___
    완전 연소한 불은 재를 남기지않는다 : 코딩배우는학생 🌎

    티스토리툴바