Skip to content

Instantly share code, notes, and snippets.

@tsuzu
Created December 11, 2016 13:47
Show Gist options
  • Save tsuzu/e77343dbdeae22683169f83c6258343d to your computer and use it in GitHub Desktop.
Save tsuzu/e77343dbdeae22683169f83c6258343d to your computer and use it in GitHub Desktop.
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