Advertisement
Josif_tepe

Untitled

Apr 4th, 2023
955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <vector>
  4. //#include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7. typedef long long ll;
  8. int main() {
  9.     ios_base::sync_with_stdio(false);
  10.     int n;
  11.     cin >> n;
  12.     vector<ll> cnt(1005, 0);
  13.     ll sum = 0;
  14.     for(int i = 0; i < n; i++) {
  15.         int a, b;
  16.         cin >> a >> b;
  17.         sum += b;
  18.        
  19.         cnt[a] += b;
  20.        
  21.         ll tmp_sum = 0;
  22.        
  23.         for(int j = 0; j <= 1000; j++) {
  24.             tmp_sum += cnt[j];
  25.             if(tmp_sum >= (sum + 1) / 2) {
  26.                 cout << j << "\n";
  27.                 break;
  28.             }
  29.         }
  30.     }
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement