-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeed_limit.cpp
More file actions
49 lines (31 loc) · 746 Bytes
/
speed_limit.cpp
File metadata and controls
49 lines (31 loc) · 746 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
40
41
42
43
44
45
46
47
48
49
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
int cases;
vector<int>dis;
int x=0;
cin >> cases;
while(cases!= -1){
vector<int>times;
for(int i=0;i<cases;i++){
int mile,time;
cin>> mile>>time;
int temp1=time;
times.push_back(temp1);
if(i==0){
x=(mile*time);
}else{
x=x+(mile*(time-times[i-1]));
}
}
dis.push_back(x);
cin >> cases;
x=0;
}
for(int j=0;j<dis.size();j++){
cout<<dis[j]<<" miles"<<endl;
}
return 0;
}