poj 2393

506 단어 알고리즘
Source Code

Problem: 2393		
Memory: 252K		Time: 94MS
Language: C++		Result: Accepted
Source Code
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int N, S;
    cin >> N >> S;
    int P = 5000;
    long long costs = 0;
    for (int i = 0; i < N; ++i)
    {
        int C, Y;
        cin >> C >> Y;
        P = min(P + S, C);
        costs += P * Y;
    }
    cout << costs << endl;
	return 0;
}

좋은 웹페이지 즐겨찾기