daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Jul 23rd, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. inline int min(int a, int b) {
  9.     if (a < b)
  10.         return a;
  11.     return b;
  12. }
  13.  
  14. inline int max(int a, int b) {
  15.     if (a > b)
  16.         return a;
  17.     return b;
  18. }
  19.  
  20. const int inf = 0x3f3f3f3f;
  21.  
  22. int main() {
  23.     ifstream cin("joc.in");
  24.     ofstream cout("joc.out");
  25.     int N; cin >> N;
  26.     vector<int> best(101, 0);
  27.  
  28.     for (int i = 0; i < N;   i) {
  29.         int d, p; cin >> d >> p;
  30.         vector<int> newbest(101, inf);
  31.         for (int j = 1; j <= 100;   j) {
  32.             int newpoints = min(100, j   d);
  33.             if (newpoints > p)
  34.                 newbest[newpoints - p] = min(newbest[newpoints - p], best[j]);
  35.  
  36.             newbest[newpoints] = min(newbest[newpoints], best[j]   1);
  37.         }
  38.         swap(best, newbest);
  39.     }
  40.  
  41.     cout << *min_element(best.begin()   1, best.end()) << "\n";
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top