알고리즘

[알고리즘] 백준 10409 - 서버 (C++)

blueberrysoda 2024. 11. 18. 22:26

[문제 링크] : https://www.acmicpc.net/problem/10409

#include <iostream>
using namespace std;

int N, M, Ans;
int Arr[51];

int main(){
    cin >> N >> M;

    int sum = 0;

    for(int i=0; i<N; i++){
        cin >> Arr[i];
        sum += Arr[i];

        if(sum <= M){
            Ans++;
        }
    }

    cout << Ans << "\n";
    return 0;
}