Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MAXN 5050
- #define pb push_back
- #define INF 10000000
- using namespace std;
- typedef pair <int, int> pii;
- typedef long long ll;
- int main() {
- ofstream fout ("barn1.out");
- ifstream fin ("barn1.in");
- int m, s, c;
- fin >> m >> s >> c;
- priority_queue <int> fila;
- int stalls[MAXN];
- for(int i = 1; i <= c; i++){
- fin >> stalls[i];
- }
- sort(stalls + 1, stalls + c + 1);
- int anterior = stalls[1] + 1, atual;
- for(int i = 1; i <= c; i++){
- atual = stalls[i];
- fila.push(atual - anterior - 1);
- anterior = atual;
- }
- int sum = (stalls[c] - stalls[1]) + 1;
- for(int i = 1; i <= m - 1; i++){
- sum -= fila.top();
- fila.pop();
- }
- if(m > c) fout << c << endl;
- else fout << sum << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment