안녕하세요. 오늘은 페널티를 계산할 거예요.

문제

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

아이디어

최댓값을 찾아서 f, ft, fs를 저장한 뒤에 계산을 해주면 됩니다.

소스코드

#include <iostream>
#define ll long long
using namespace std;

int main(void)
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll N, i, t, s, f = 0, mx = 0, tf = 0, sf = 0;

    cin >> N;
    for (i = 1; i <= N; i++)
    {
        cin >> t >> s;
        if (s > mx)
        {
            mx = s;
            f = i;
            tf = t;
            sf = s;
        }
    }
    if (sf == 0) cout << 0;
    else cout << tf + (f - 1) * 20;
}


감사합니다.

1개의 댓글

comment-user-thumbnail
2024년 1월 14일

풀이 공유 감사합니다 :)

답글 달기