Advertisement
Ritam_C

Uri 1023

Jan 13th, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define pb push_back
  5. #define p_b pop_back
  6. using namespace std;
  7.  
  8. int main(){
  9.     ios_base::sync_with_stdio(false);
  10.     cin.tie(NULL);
  11.  
  12.     int c = 0;
  13.     while(true){
  14.         c++;
  15.         int n, vol = 0, tot = 0;
  16.         cin >> n;
  17.         if(n == 0){
  18.             break;
  19.         }
  20.         map<int, int> m;
  21.         for(int i = 0; i < n; i++){
  22.             int k, v;
  23.             cin >> k >> v;
  24.             m[v/k] += k;
  25.             vol += v;
  26.             tot += k;
  27.         }
  28.  
  29.         cout << "Cidade# " << c << ":\n";
  30.         for(auto i = m.begin(); i != m.end(); i++){
  31.             cout << i->second << "-" << i->first << " ";
  32.         }
  33.  
  34.         double av = 1.0*vol/tot;
  35.  
  36.         cout << "\nConsumo medio: " << fixed << setprecision(2) << av << " m3\n";
  37.         cout << "\n";
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement