-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva11679.cpp
More file actions
61 lines (51 loc) · 1.42 KB
/
Copy pathUva11679.cpp
File metadata and controls
61 lines (51 loc) · 1.42 KB
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
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
using namespace std;
typedef pair<int,pair<int,int>> pdr;
int main()
{
int numberOfBanks,numberOfDebentures;
scanf("%d %d",&numberOfBanks,&numberOfDebentures);
while(true){
if(numberOfBanks==0 && numberOfDebentures==0)break;
vector<int> reserves;
int res;
for(int i=0;i<numberOfBanks;i++){
scanf("%d",&res);
reserves.push_back(res);
}
vector<pdr> kolekciq;
int dlujnik,kreditor,razmerDulg;
for(int i=0;i<numberOfDebentures;i++){
scanf("%d %d %d",&dlujnik,&kreditor,&razmerDulg);
kolekciq.push_back(make_pair(razmerDulg,make_pair(dlujnik,kreditor)));
}
for(int i=0;i<kolekciq.size();i++){
int dulg=kolekciq[i].first;
pair<int,int> cust=kolekciq[i].second;
int dlujn=cust.first;int kred=cust.second;
reserves[dlujn-1]-=dulg;
reserves[kred-1]+=dulg;
}
bool mark=true;
for(int i=0;i<reserves.size();i++){
if(reserves[i]<0){
mark=false;
}
}
if(mark){
cout<<"S"<<endl;
}
else{
cout<<"N"<<endl;
}
scanf("%d %d",&numberOfBanks,&numberOfDebentures);
}
return 0;
}