1 solutions

  • 0
    @ 2025-7-16 15:43:40

    #include <bits/stdc++.h> using namespace std;

    int main() { int a[100005]; int n, b; cin >> n >> b; for (int i = 1; i <= n; i++) { cin >> a[i];

    }
    for (int j = 1; j <= n; j++) {
    	b = b - a[j];
    	if (b <= 0) {
    		cout << j;
    		break;
    	}
    }
    if (b > 0) {
    	cout << "-1";
    }
    
    return 0;
    

    }

    Information

    ID
    336
    Time
    1000ms
    Memory
    64MiB
    Difficulty
    2
    Tags
    # Submissions
    72
    Accepted
    42
    Uploaded By