※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 26565번 문제인 Time Limits이다.
문제는 아래 링크를 확인하자.

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

 

26565번: Time Limits

The first line of input will contain a single integer m that indicates the number datasets to follow. Each dataset is comprised of two lines. The first line of input contains two space-separated integers n and s (1 ≤ n ≤ 100 and 1 ≤ s ≤ 20). The se

www.acmicpc.net

주어지는 n개의 수중 가장 큰 수에 s를 곱해 ms단위의 시간제한 최솟값 구할 수 있다.

 

위에서 계산한 ms단위의 시간제한을 이용해 초단위 시간제한을 계산해 문제를 해결하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;

int T;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> T;
	while (T--) {
		int mx = 0;
		int N, S; cin >> N >> S;
		while (N--) {
			int x; cin >> x;
			mx = max(mx, x);
		}

		cout << (mx * S - 1) / 1000 + 1 << '\n';
	}
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 20112 // C++] 사토르 마방진  (0) 2022.12.23
[BOJ 17828 // C++] 문자열 화폐  (0) 2022.12.23
[BOJ 26544 // C++] Histogram Fencing  (0) 2022.12.23
[BOJ 11580 // C++] Footprint  (0) 2022.12.23
[BOJ 26731 // C++] Zagubiona litera  (0) 2022.12.23

+ Recent posts