-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicpc7301.cpp
More file actions
36 lines (33 loc) · 745 Bytes
/
icpc7301.cpp
File metadata and controls
36 lines (33 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
// freopen("input.txt", "r", stdin);
int ncase, N, L, value;
int ansA, ansB, ansC;
int accum = 0;
int preV = 0;
vector<int> vec;
scanf("%d", &ncase);
for(int i = 1; i <= ncase; ++i) {
scanf("%d%d", &N, &L);
for(int v = 0 ; v < N; ++v) {
scanf("%d", &value);
vec.push_back(value);
}
sort(vec.begin(), vec.end());
accum = 0;
ansA = ansB = ansC = 0;
for(int z = 0; z < vec.size(); ++z) {
if(ansB + vec[z] > L) break;
ansA++;
ansB += vec[z];
ansC += ansB;
}
vec.clear();
printf("Case %d: %d %d %d\n", i, ansA, ansB, ansC);
}
return 0;
}