-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode1376148.cc
More file actions
38 lines (29 loc) · 853 Bytes
/
code1376148.cc
File metadata and controls
38 lines (29 loc) · 853 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
#include <iostream>
#include <vector>
using namespace std;
int main() {
unsigned broj_dece;
cin >> broj_dece;
vector<unsigned> cene(broj_dece);
for(unsigned i = 0; i < broj_dece; i++)
cin >> cene[i];
unsigned broj_upita;
cin >> broj_upita;
vector<pair<unsigned, unsigned>> upiti(broj_upita);
for(unsigned i = 0; i < broj_upita; i++) {
unsigned pozicija, budzet;
cin >> pozicija >> budzet;
upiti[i] = {pozicija, budzet};
}
for(unsigned i = 0; i < broj_upita; i++) {
unsigned j = upiti[i].first, tmp = upiti[i].second;
unsigned kupljeno = 0;
while(tmp > cene[j] && j < cene.size()) {
tmp -= cene[j];
kupljeno++;
j++;
}
cout << kupljeno << '\n';
}
return 0;
}