Advertisement
Josif_tepe

Untitled

Aug 17th, 2024
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.    int n, k;
  7.    cin >> n >> k;
  8.    
  9.    n = 2 * (n - 1);
  10.    int wins = 2e9, losses = 2e9, draws = 2e9;
  11.    for(int x = 0; x <= n; x++) {
  12.       for(int y = 0; y <= n; y++) {
  13.          if(x + y <= n) {
  14.             int z = n - x - y;
  15.             if(3 * x + y == k) {
  16.                if(z < losses) {
  17.                   wins = x;
  18.                   losses = z;
  19.                   draws = y;
  20.                }
  21.             }
  22.          }
  23.       }
  24.    }
  25.    cout << wins << " " << draws << " " << losses << endl;
  26.  
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement