Advertisement
dejmas

D1 TLE

May 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define FOR( i, f, t) for(int i = (f); i < (t); ++i)
  4. #define D(x) cout <<"  "#x": " << x << endl;
  5. #define DRI(a) int a; cin >> a;
  6. map<int, int> lang;
  7.  
  8.  
  9. int main(){
  10.    
  11.     DRI(n); DRI(k);
  12.     vector< int > a(n), b(n), c(n);
  13.    
  14.     FOR( i, 0, n ){
  15.         DRI(x);
  16.         a[i] = x;
  17.     }
  18.    
  19.     FOR( i, 0, n ){
  20.         DRI(x);
  21.         b[i] = x;    
  22.     }
  23.  
  24.     int times = 0xffffff;
  25.     FOR( i, 0, n ){
  26.         int t = b[i] / a[i];
  27.         if( t < times ){
  28.             times = t;
  29.         }
  30.     }
  31.     while( k > 0 ){
  32.         FOR( i, 0, n ){
  33.             if( b[i] / a[i] == times ) {
  34.                 int need = a[i] - (b[i] % a[i]);
  35.                 if( k >= need ) k -= need;
  36.                 else{
  37.                     k = 0; times --; break;
  38.                 }
  39.             }
  40.         }
  41.         times ++;
  42.     }
  43.     cout << times << endl;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement