# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
925276 |
2024-02-11T09:58:14 Z |
Zygno |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct guest
{
int start;
int end;
};
struct breakLength
{
int start;
int length;
};
int main()
{
int n; // Number of guests
int k; // Number of matches
cin >> n >> k;
vector<guest> guests(n);
vector<breakLength> breaks(n-1);
for (int i = 0; i < n; i++)
{
int temp = 0;
cin >> temp;
guests[i].start = temp;
guests[i].end = temp+1;
if (i > 0)
{
breaks[i-1].start = guests[i].start;
breaks[i-1].length = guests[i].start - guests[i-1].end; //Length of break between guests
}
}
//Order breaks by length
sort(breaks.begin(), breaks.end(), [](breakLength a, breakLength b) { return a.length > b.length; });
//Number of breaks where stove can be turned off
int breaksOn = n - k;
int breaksOff = n - breaksOn - 1;
int stoveOn = 0;
//Add the length of the longest breaks
for (int i = 0; i < breaksOff; i++)
{
stoveOn += breaks[i].length;
}
int timeOn = guests[n-1].end - stoveOn - 1;
cout << timeOn << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |