Skip to content

Commit

Permalink
주유소
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Apr 22, 2022
1 parent d96f7ed commit b1d6008
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions greedy_algorithm/13305.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
using namespace std;
#define INF 987654321;
long long dis[100000];
long long price[100000];

int main() {
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
cin >> dis[i];
}
for (int i = 0; i < n; i++) {
cin >> price[i];
}
long long minv = INF;
long long result = 0;
for (int i = 0; i < n - 1; i++) {
minv = min(minv, price[i]);
result += minv * dis[i];
}
cout << result;
}

0 comments on commit b1d6008

Please sign in to comment.