Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
JOI 2017 Yo 2nd
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <cmath>
#include <cstring>
int n, m;
int arr[1010];
int main() {
std::cin >> n >> m;
int tmp;
for(int i = 0; i < m; ++i) {
std::cin >> arr[i] >> tmp;
}
std::sort(arr, arr + m, std::greater<int>());
int ans = 0;
for(int i = 0; i < m - 1; ++i) {
ans += std::max(n - arr[i], 0);
}
std::cout << ans << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment