Advertisement
newb_ie

Untitled

Nov 25th, 2021
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2.  
  3. using namespace std;
  4.  
  5. int main () {
  6. ios::sync_with_stdio(false);
  7. cin.tie(nullptr);
  8. cout.tie(nullptr);
  9. int rows = 40;
  10. int start = 1;
  11. vector<int> seat_second;
  12. for (int row = 1; row <= rows; ++row) {
  13. //row = 2
  14. //start = 2
  15. seat_second.push_back(start);
  16. seat_second.push_back(start);
  17. seat_second.push_back(start + 1);
  18. seat_second.push_back(start + 1);
  19. seat_second.push_back(start + 2);
  20. seat_second.push_back(start + 2);
  21. start += 1;
  22. }
  23. sort(seat_second.rbegin(),seat_second.rend());
  24. //~ for (int i = 0; i < (int) seat_second.size(); ++i) cout << seat_second[i] << ' ';
  25. int T;
  26. cin >> T;
  27. for (int i = 1; i <= T; ++i) {
  28. int n;
  29. cin >> n;
  30. int cost = n * (n - 1) / 2;
  31. for (int j = 1; j <= n; ++j) {
  32. cost += seat_second.back();
  33. seat_second.pop_back();
  34. }
  35. cout << cost << '\n';
  36. }
  37. }
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement