Skip to content

Commit

Permalink
ABC357A Sanitize Hands
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Jun 10, 2024
1 parent 98ca109 commit a9b1bbf
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions atcoder/abc357a_sanitize_hands.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Vicfred
// https://atcoder.jp/contests/abc357/tasks/abc357_a
// implementation
#include <iostream>
#include <vector>

using namespace std;

int main() {
int N, M;
cin >> N >> M;
vector<int> H(N);
for(int i = 0; i < N; ++i) {
cin >> H[i];
}
int aliens = 0;
for(int i = 0; i < N; ++i) {
aliens++;
M -= H[i];
if(M <= 0) {
break;
}
}
if(M < 0) {
aliens--;
}
cout << aliens << endl;
return 0;
}

0 comments on commit a9b1bbf

Please sign in to comment.