【題解】Codeforces 1316A. Grade Allocation

【題目敘述】http://codeforces.com/contest/1316/problem/A

#include <iostream>
using namespace std;
 
int t, n, m, a, total;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n >> m;
        total = 0;
        for (int i = 0; i < n; i++){
            cin >> a;
            total += a;
        }
        cout << min(total, m) << "\n";
    }
}
分享本文 Share with friends