P4745 B’s problem(b)

 1 #include<iostream>
 2 #include<algorithm>
 3 using namespace std;
 4 int a[10001];
 5 int tot;//食堂阿姨手里的钱 
 6 int ans;//
 7 int main()
 8 {
 9     int n;
10     cin>>n;
11     for(int i=1;i<=n;i++)
12     {
13         cin>>a[i];
14     }
15     sort(a+1,a+n+1);
16     for(int i=1;i<=n;i++)
17     {
18         if(a[i]==25)
19         {
20             tot=tot+25;
21         }
22         else if(a[i]==50)
23         {
24             tot=tot+25;
25         }
26         else if(a[i]==100)
27         {
28             tot=tot-75;
29         }
30     }
31     if(tot>=0)
32     cout<<"YES";
33     else 
34     cout<<"NO";
35     return 0;
36 }
原文地址:https://www.cnblogs.com/zwfymqz/p/6601982.html