forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acm2.cpp
45 lines (35 loc) · 807 Bytes
/
acm2.cpp
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
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int n, p;
cin >> n >> p;
vector<int> v;
for(int i = 0; i < n; i++) {
int temp;
cin >> temp;
v.push_back(temp);
}
int currentTime = 0;
int timeTaken = 0;
if(v[p] >= 300) {
cout << "0 0" << endl;
return 0;
}
currentTime = v[p];
timeTaken = v[p];
v.erase(v.begin() + p);
sort(v.begin(), v.end());
int solved;
for(int i = 0; i < v.size(); i++) {
solved = i;
currentTime += v[i];
if(currentTime > 300) {
cout << i + 1 << " " << timeTaken << endl;
return 0;
}
timeTaken += currentTime;
}
cout << solved + 2 << " " << timeTaken << endl;
}