-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bomboane.cpp
47 lines (38 loc) · 1.04 KB
/
Bomboane.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
#include<iostream>
#include<vector>
using namespace std;
int main(){
int zile;
int bani;
int fericire_zi;
int pret_bomboana;
int aroma_max=0;
vector<int>ban;
vector<pair<int,int>>vec;
int fericire_total=0;
cin>>zile;
for(int i=0;i<zile;i++){
cin>>bani;
ban.push_back(bani);
}
for(int i=0;i<zile;i++){
cin>>pret_bomboana>>fericire_zi;
vec.push_back(make_pair(pret_bomboana,fericire_zi));
}
for(int i=0;i<zile;i++){
if(ban[i]>=vec[i].first){
ban[i+1]+=ban[i]-vec[i].first;
if(aroma_max<=vec[i].second){
aroma_max=vec[i].second;
}
fericire_total+=vec[i].second;
}
if(ban[i]<vec[i].first){
ban[i+1]+=ban[i];
if(aroma_max<=vec[i].second){
fericire_total-=vec[i].second;
}
}
}
cout<<fericire_total;
}