5 条题解

  • 1
    @ 2025-4-13 11:27:53
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,x,y,bu=0;
    	cin>>n>>x;
    	int s=n;
    	for(int i=1;i<=x;i++)
    	{
    	 cin>>y;
    	 if(y<=s) s=s-y;
    	 else bu++;
    	}cout<<bu<<endl;
    	return 0;
    }
    
    
    • 1
      @ 2025-2-3 16:52:54
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int n,x,y,bu=0;
      	cin>>n>>x;
      	int s=n;
      	for(int i=1;i<=x;i++)
      	{
      	 cin>>y;
      	 if(y<=s) s=s-y;
      	 else bu++;
      	}cout<<bu<<endl;
      	return 0;
      }
      
      • 1
        @ 2025-2-3 16:45:52
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
        	int n,x,y,bu=0;
        	cin>>n>>x;
        	for(int i=1;i<=x;i++)
        	{
        	 cin>>y;
        	 if(y<=n) n=n-y;
        	 else bu++;
        	}cout<<bu<<endl;
        	return 0;
        }
        
        • 1
          @ 2025-2-2 22:54:39
          #include<iostream>
          using namespace std;
          int main(){
              int m,n,b=0;
              cin>>m>>n;
              int a[n];
              for(int i=1;i<=n;i++){
                  cin>>a[i];
                  if(a[i]>m){
                      b++;
                  }else{
                      m-=a[i];
                  }
              }
              cout<<b;
              return 0; 
          }
          
          • 1
            @ 2025-1-19 20:27:25
            #include<bits/stdc++.h>
            using namespace std;
            int main(){
                int cnt = 0;
                int shengy,N,a;
                cin >> shengy >> N;
                for (int i = 0;i < N;i++){
                	cin >> a;
                	if (shengy < a) cnt++;//取不到药的病人+1
                	else shengy = shengy - a;//药=药-需要量
                }
            	cout << cnt;
                return 0;
            }
            
            • 1

            信息

            ID
            66
            时间
            1000ms
            内存
            128MiB
            难度
            1
            标签
            (无)
            递交数
            71
            已通过
            47
            上传者