[백준] 13305 주유소

0

백준

목록 보기
180/271
post-thumbnail

[백준] 13305 주유소

#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n;
	cin >> n;

	vector<ll> dist;
	for (int i = 0; i < n-1; ++i) {
		ll input;
		cin >> input;
		dist.push_back(input);
	}
	vector<ll> cost;
	for (int i = 0; i < n; ++i) {
		ll input;
		cin >> input;
		cost.push_back(input);
	}

	ll totalCost = cost[0] * dist[0];
	ll minCost = cost[0];
	for (int i = 1; i < n-1; ++i) {
		minCost = min(minCost, cost[i]);
		totalCost += minCost * dist[i];
	}
	cout << totalCost;

	return 0;
}
profile
Be able to be vulnerable, in search of truth

0개의 댓글