P4745 B’s problem(b)

时间:2022-05-10
本文章向大家介绍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 }