fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7.  
  8. while (t--) {
  9. int n;
  10. cin >> n;
  11.  
  12. int m = 0, r = n;
  13. while (m < r) {
  14. int mid = (m + r) / 2;
  15. if (3 + 3 * mid <= n - 3) {
  16. m = mid + 1;
  17. } else {
  18. r = mid;
  19. }
  20. }
  21.  
  22. cout << m - 1 << endl;
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5288KB
stdin
3
5
1 2 3 4 5
1
1033
5
600 900 1300 2000 2550
stdout
-1
-1
-1