-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13305.cpp
More file actions
39 lines (35 loc) · 788 Bytes
/
Copy path13305.cpp
File metadata and controls
39 lines (35 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
long long gas[100005] = {0};
long long dis[100005] = {0};
int main() {
long long n,a;
long long result=0;
scanf("%lld", &n);
for(int i=0; i<n-1; i++){
scanf("%lld", &a);
dis[i]=a;
}
for(int i=0; i<n; i++){
scanf("%lld", &a);
gas[i]=a;
}
long long now = gas[0];
long long nowdis = 0;
for(int i=0; i<n-1; i++){
nowdis += dis[i];
if(now > gas[i+1]){
result += (now*nowdis);
nowdis=0;
now = gas[i+1];
}
}
if(nowdis!=0){
result += (now*nowdis);
}
printf("%lld", result);
return 0;
}