-
Notifications
You must be signed in to change notification settings - Fork 1
/
Banda transportoare.cpp
90 lines (77 loc) · 2.28 KB
/
Banda transportoare.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<iostream>
#include<vector>
#include <math.h>
using namespace std;
int main(){
long long int n,timp,senzor,rez,aux,aux2,aux1,aux3,aux4;
long long int cnt=0;
cin>>n;
vector<pair<long long int,long long int>>dreapta;
vector<pair<long long int,long long int>>stanga;
for(long long int i=0;i<n;i++){
cin>>timp>>senzor;
stanga.push_back(make_pair(timp,senzor));
}
for(long long int i=0;i<n;i++){
cin>>timp>>senzor;
dreapta.push_back(make_pair(timp,senzor));
}
for(long long int i=0;i<stanga.size();i++){
if(stanga[i].second==1){
aux=stanga[i].first;
break;
}
}
for(long long int i=0;i<dreapta.size();i++){
if(dreapta[i].second==1){
aux2=dreapta[i].first;
break;
}
}
if(aux<aux2){
aux1=1;
}else{aux1=-1;}
vector<long long int>saux;
vector<long long int>daux;
for(long long int i=0;i<stanga.size();i++){
if(stanga[i].second==1){
cnt++;
for(long long int j=i;j<stanga.size();j++){
if(stanga[j].second==0||j==stanga.size()-1){
saux.push_back((stanga[i].first/10)*10);
i=j;
break;
}
}
}continue;
}
for(long long int i=0;i<dreapta.size();i++){
if(dreapta[i].second==1){
for(long long int j=i;j<dreapta.size();j++){
if(dreapta[j].second==0||j==dreapta.size()-1){
daux.push_back((dreapta[i].first/10)*10);
i=j;
break;
}
}
}continue;
}
vector<long double>rezz;
for(int i=0;i<saux.size();i++){
rezz.push_back((saux[i]-daux[i]));
}
int cv=1;
long double final=0;
for(long long int i=0;i<rezz.size();i++){
if(rezz[i]!=0){
rezz[i]=(3600/(rezz[i]));
final+=rezz[i];
}else cv*=10;
}
if(cv!=1){
final*=cv/10;
}
long double viteza;
viteza=abs(final/rezz.size());
cout<<round(viteza*0.2778*0.2)<<' '<<cnt;
}