きっとブログ
130 words
1 minutes
【ABC332】A - Online Shopping

問題#

問題ページへのリンクはこちら

コード#

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int N, S, K, price, num, total = 0;
  
  cin >> N >> S >> K;
  
  rep(i, N) {
    cin >> price >> num;  // 商品の金額を受け取って
    total = total + price * num;  // 値段*個数を計算して足し合わせる
  }
  if ( total < S ) {  // 送料タダのボーダーを超えていなかったら
    total += K;  // totalに送料を追加
  }

  cout << total << endl;
}