Recent Posts
Notice
No Rules Rules
Speed Limit (feat. 백준, 14541번) 본문
728x90
반응형
Speed Limit
https://www.acmicpc.net/problem/14541
반응형
// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
using namespace std;
int main(){
ios::sync_with_stdio(false), cin.tie(NULL);
register int N, S, T;
while(1){
cin >> N;
if(N == -1)
break;
register int ans = 0, t = 0;
for(register int n = 0; n < N; ++n){
cin >> S >> T;
ans += S * (T - t);
t = T;
}
cout << ans << " miles\n";
}
return 0;
}
// *&)*@*
N개의 S, T를 입력받은 경우, Pn = Sn * (Tn - Tm) (m은 n-1) 의 수식이 성립됩니다.
따라서 P1 + P2 + ... + Pn 의 결과를 정답으로 출력하면 됩니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
Dyslexia (feat. 백준, 8371번) (0) | 2022.09.08 |
---|---|
Speed Limit (feat. 백준, 4635번) (0) | 2022.09.08 |
Ship Selection (feat. 백준, 10180번) (0) | 2022.09.08 |
꿍의 우주여행 (feat. 백준, 9501번) (0) | 2022.09.08 |
Atrium (feat. 백준, 20353번) (0) | 2022.09.08 |
Comments