본문 바로가기

Programming/BaekJoon

[C++] 백준 10409번 : 서버


https://www.acmicpc.net/problem/10409




#include <iostream>

using namespace std;

int main() {

int n, t;

cin >> n >> t;


int a,sum=0,cnt=0;


for (int i = 0; i < n; i++) {

cin >> a;

sum += a;

if (sum <= t)

cnt++;

}

cout << cnt;

}