2 solutions

  • 2
    @ 2024-5-24 11:18:12
    #include<bits/stdc++.h>
    using namespace std;
    int main() 
    {
    	int a,b,c,k=0;
    	cin>>a>>b;
    	for(int i=1;i<=b;i++)
    	{
    		cin>>c; //当前取到的药的数量 
    		if(c<=a) //可以取 
    		{
    			a=a-c;
    		}
    		else //取不到 
    		{
    			k=k+1;	
    		}
    		
    	}
    	cout<<k;
    	return 0;
    }
    
    • 1
      @ 2025-6-14 10:44:22

      #include<bits/stdc++.h> using namespace std; int main() { int a,b,c,k=0; cin>>a>>b; for(int i=1;i<=b;i++) { cin>>c; //当前取到的药的数量 if(c<=a) //可以取 { a=a-c; } else //取不到 { k=k+1; }

      }
      cout<<k;
      return 0;
      

      }

      • 1

      Information

      ID
      880
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      155
      Accepted
      66
      Uploaded By