Created
December 11, 2016 12:14
-
-
Save gedorinku/a2eff1006ae647b063892396b35ce9a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define int long long | |
#define PB push_back | |
#define PPB pop_back | |
#define MK make_pair | |
#define ALL(V) V.begin(), V.end() | |
typedef pair<int, int> pii; | |
typedef pair<double, double> pdd; | |
typedef pair<string, int> psi; | |
typedef pair<int, pii> pipii; | |
constexpr int INF = 1LL << 61; | |
//constexpr int MOD = 1000000007; | |
//constexpr int MAX_N = 55; | |
int n, m; | |
vector<int> hoge; | |
signed main() { | |
ios::sync_with_stdio(false); | |
cin.tie(0); | |
cin >> n >> m; | |
for (int i = 0; i < m; ++i) { | |
int a, b; | |
cin >> a >> b; | |
if (n <= a) continue; | |
hoge.PB(n - a); | |
} | |
sort(ALL(hoge)); | |
int ans = 0; | |
for (int i = 0; i < hoge.size() - 1; ++i) ans += hoge[i]; | |
cout << ans << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment