algorithms

Algorithm implementations
git clone git://git.laack.co/algorithms.git
Log | Files | Refs | README

c.cpp (706B)


      1 #include <iostream>
      2 #include <vector>
      3 #include <unordered_set>
      4 #include <unordered_map>
      5 #include <algorithm>
      6 #include <queue>
      7 
      8 #define ll long long
      9 
     10 using namespace std;
     11 
     12 // 2 rows
     13 // m seats each
     14 // a + b + c monkeys in class
     15 // a only want to sit in row 1
     16 // b in row 2
     17 // c don't give a fuck
     18 
     19 int main() {
     20     int testCases, m,a,b,c;
     21     cin >> testCases;
     22 
     23 
     24     for(int z = 0; z < testCases; ++z) {
     25         cin >> m;
     26         cin >> a;
     27         cin >> b;
     28         cin >> c;
     29         
     30         int firstRowSeated = min(m,a);
     31         int secondRowSeated = min(m,b);
     32         int rem = min((m - firstRowSeated) + (m - secondRowSeated), c);
     33         cout << rem + firstRowSeated + secondRowSeated << endl;
     34     }
     35 }