5 solutions

  • 5
    @ 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;
    }
    
    • 0
      @ 2026-2-3 10:06:04

      cpp, #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
        @ 2026-2-3 10:05:48

        #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
          @ 2026-2-3 10:04:47
          #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;
          }
          
          • -2
            @ 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
            215
            Accepted
            85
            Uploaded By