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

공지사항

인기 글

태그

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

최근 댓글

최근 글

티스토리

hELLO
Blue___

코딩배우는 학생🌎

[Codeforce/round#611] Minutes Before the New Year [Java]
Algorithms/Coding_Contest

[Codeforce/round#611] Minutes Before the New Year [Java]

2019. 12. 29. 10:22

time limit per test

1 second

memory limit per test

256 megabytes

input: standard input

output: standard output

 

New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows ℎh hours and 𝑚m minutes, where 0≤ℎℎ<240≤hh<24 and 0≤𝑚𝑚<600≤mm<60. We use 24-hour time format!

Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows 00 hours and 00 minutes.

You have to answer 𝑡t independent test cases.

 

Input

The first line of the input contains one integer 𝑡t (1≤𝑡≤14391≤t≤1439) — the number of test cases.

The following 𝑡t lines describe test cases. The 𝑖i-th line contains the time as two integers ℎh and 𝑚m (0≤ℎ<240≤h<24, 0≤𝑚<600≤m<60). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: ℎ=0h=0 and 𝑚=0m=0. It is guaranteed that both ℎh and 𝑚m are given without leading zeros.

 

Output

For each test case, print the answer on it — the number of minutes before the New Year.

 


Solution

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.*;
import javax.swing.text.AbstractDocument.BranchElement;
import java.io.*;
 
public class Main {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n=Integer.parseInt(br.readLine()); //test case입력 
        int sum=0;
        for(int i=0;i<n;i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int h=Integer.parseInt(st.nextToken());
            int m=Integer.parseInt(st.nextToken());
            sum+=(23-h)*60;
            sum+=60-m;
            System.out.println(sum);
            sum=0;
        }
        
        
}
}
 
 

 

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

'Algorithms > Coding_Contest' 카테고리의 다른 글

[그래프 위상정렬] Topological Sort : Java  (0) 2021.07.20
[NWERC 2006] Printer Queue [Java]  (0) 2020.07.25
    'Algorithms/Coding_Contest' 카테고리의 다른 글
    • [그래프 위상정렬] Topological Sort : Java
    • [NWERC 2006] Printer Queue [Java]
    Blue___
    Blue___
    완전 연소한 불은 재를 남기지않는다 : 코딩배우는학생 🌎

    티스토리툴바