Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Created July 12, 2017 19:19
Show Gist options
  • Save MohamedTaha98/1d68a72d4a0dc92a704e18ef52b07184 to your computer and use it in GitHub Desktop.
Save MohamedTaha98/1d68a72d4a0dc92a704e18ef52b07184 to your computer and use it in GitHub Desktop.
Problem Solving
#include <iostream>
#include <math.h>
using namespace std;
int main() {
long long n, m, k, r, val;
cin >> n >> m >> k;
long long c[m], rmn = k;
for (int i = 0; i < m; i++)
c[i] = pow(10,6);
for (int i = 0; i < n; i++) {
cin >> r >> val;
r--;
if (val < c[r])
c[r] = val;
}
for (int i = 0; i < m; i++)
rmn -= c[i];
if (rmn < 0)
cout << k;
else
cout << k - rmn;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment