Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class C { static boolean solve(long n, long k, long d1, long d2) { if(n%3 == 0) { long d3 = 0; long min = Math.min(Math.min(d1, d2), 0); if(min < 0) { d1 += -min; d2 += -min; d3 += -min; } long end = d1 + d2 + d3; if(k - end >= 0 && (k - end)%3 == 0) ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import * t=int(stdin.readline()) for i in range(t): n,k,d1,d2=(int(z) for z in stdin.readline().split()) vars=((2*d1+d2,2*d2+d1),(2*d2+d1,2*d1+d2),(2*max(d1,d2)-min(d1,d2),d1+d2), (d1+d2,2*max(d1,d2)-min(d1,d2))) y=False for i in vars: if i[0]<=k and i[0]%3==k%3 and n-k-i[1]>=0 and (n-...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
input=__import__('sys').stdin.readline for _ in range(int(input())): n,k,d1,d2 = map(int,input().split()) lis=[[2*d1+d2 , 2*d2+d1] , [2*d2+d1 , 2*d1+d2] , [2*max(d1,d2)-min(d1,d2) , d1+d2] , [d1+d2 , 2*max(d1,d2) - min(d1,d2)]] flag=1 for i in lis: if i[0]<=k and i[0]%3==k%3 and n-k-i[1]>=0 and ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner sc=new Scanner(System.in); L:for(int t = (int)sc.nextLong();t>0;t--){ long n = sc.nextLong(); long k = sc.nextLong(); long d1 = sc.nextLong(); long d2 = sc.nextLong(); if(n%3!=0){ System.out.println("no"...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import stdin rints = lambda: [int(x) for x in stdin.readline().split()] for _ in range(int(input())): n, k, d1, d2 = rints() cases, ans = [[d1, 0, d2], [0, d1, d1 + d2], [d2 + d1, d2, 0]], 'no' if d1 >= d2: cases.append([0, d1, d1 - d2]) if d2 >= d1: cases.append([d2 - d1, d2,...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import static java.lang.Math.*; import static java.lang.System.currentTimeMillis; import static java.lang.System.exit; import static java.lang.System.arraycopy; import static java.util.Arrays.sort; import static java.util.Arrays.binarySearch; import static java.util.Arrays.fill; import java.util.*; import java.io.*; p...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long N, k, d1, d2; bool c1() { if (k - d1 - d2 < 0) return false; if ((k - d1 - d2) % 3) return false; long long b = (k - d1 - d2) / 3; long long a = b + d1; long long c = b + d2; if (a < 0 || b < 0 || c < 0 || a + b + c != k) return false; if (a < 0 || b...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ProblemC2 { private ProblemC2() throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); String h = rd.readLine(); int t = Integer.parseInt(h); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
t=int(input()) for i in range(t): n,k,d1,d2=map(int,input().split()) m=d1+d2 mm=2*max(d1,d2)-min(d1,d2) mmm=2*d1+d2 mmmm=2*d2+d1 if (k-mmm>=0 and (k-mmm)%3==0 and n-mmmm-k>=0 and (n-mmmm-k)%3==0) or (k-mmmm>=0 and (k-mmmm)%3==0 and n-mmm-k>=0 and (n-mmm-k)%3==0) or (k-m>=0 and (k-m)%3==0 and n-m...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long t, n, k, d1, d2, m, a, b, c, x, y; bool flag; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; for (int i = 0; i < t; ++i) { cin >> n >> k >> d1 >> d2; if (n % 3 != 0) cout << "no\n"; else { m = n / 3; for (int...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn */ public class M...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int MnoD = 1000000007; const int INF = int(1e9); bool solve(long long n, long long k, long long d1, long long d2) { if (n % 3 != 0) { return false; } for (int sign1 = -1; sign1 <= 1; sign1 += 2) { for (int sign2 = -1; sign2 <= 1; sign2 += 2) { long...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == '-') { ng = true; ch = getchar(); break; } if (ch >= '0' && ch <= '9') break; } while (1) { n = n * 10 + (ch - '0'); ch = getchar(); ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T abs(T x) { return x < 0 ? -x : x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } int t; inline bool f(long long x) { return x >= 0 && x % 3 == 0; } int main() { ios...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
//package com.example.hackerranksolutions; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Compara...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool func(long long a, long long b, long long c, long long d) { if (a >= b && a >= c) { d = d - (a - b); d = d - (a - c); if (d < 0 || d % 3 != 0) return false; else return true; } else if (b >= a && b >= c) { d = d - (b - a); d = d -...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class Main { public static void main(String[] args) { TaskC mSol = new TaskC(); mSol.solve(); mSol.flush(); mSol.close(); } } class TaskC { public FasterScanner mFScanner; ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-8; static const double PI = 4.0 * atan(1.0); bool ISINT(double x) { return fabs(x - (int)round(x)) < EPS; } bool ISEQ(double x, double y) { return fabs(x - y) < EPS; } string itos(long long x) { stringstream ss; ss << x; return ss.str(); }...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import * t=int(stdin.readline()) mm,mmm,mmmm,m=0,0,0,0 for i in range(t): n,k,d1,d2=(int(z) for z in stdin.readline().split()) m=d1+d2 mm=2*max(d1,d2)-min(d1,d2) mmm=2*d1+d2 mmmm=2*d2+d1 if (k-mmm>=0 and (k-mmm)%3==0 and n-mmmm-k>=0 and (n-mmmm-k)%3==0) or (k-mmmm>=0 and (k-mmmm)%3==0 ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int cnt = (0); cnt < (t); ++cnt) { int64_t n, k, d1, d2; cin >> n >> k >> d1 >> d2; int s[] = {1, -1}; bool ok = false; for (int i = (0); i < (2); ++i) for (int j = (0); j < (2); ++j) { int64_t sum =...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool solve(long long n, long long k, long long d1, long long d2) { if ((n % 3) != 0) { return false; } for (int s1 = -1; s1 <= 1; s1 += 2) { for (int s2 = -1; s2 <= 1; s2 += 2) { long long dd1 = s1 * d1; long long dd2 = s2 * d2; if (((k - dd1...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Scanner; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top * * @author mthai */ public class Main { public static...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 111111; const int INF = 1000000000, mod = 1000000007; const long long LLINF = 1000000000000000000ll; long long n, k, d1, d2; bool try_solve(long long d1, long long d2) { if (n % 3) return 0; if ((k - d1 + d2) % 3) return 0; long long x2 = (k - d1 + d2) /...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main1 { static boolean isValid(long n, long k, long d1, long d2) { if (n % 3 != 0 || (k + 2 * d1 + d2) % 3 != 0) return false; long d = n / 3;...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.math.*; import java.util.*; import java.lang.*; public class Main { public static InputStream inputStream = System.in; public static OutputStream outputStream = System.out; public static FastReader in = new FastReader(inputStream); public static PrintWriter out = new Print...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.nio.ByteBuffer; import java.util.Arra...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
# CodeForces Problem 451C # Predict Outcome of the Game # Brian Zhang, bcubed346 # # First line contains the number of test cases (1 <= t < 10^5) # Remaining t lines contain n, k, x, y def helper(m, k, x, y): a = k + 2*x + y b = k - x + y c = k - x - 2*y if (a % 3 != 0) or (b % 3 != 0) or (c % 3 != 0):...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import sys def check(a, b, c, n, k): need = n // 3 return ((n - k) == (need - a) + (need - b) + (need - c) and a <= need and b <= need and c <= need and a >= 0 and b >= 0 and c >= 0) for tc in range(int(sys.stdin.readline())): n,k,d1,d2 = map(int, sys.stdin.readline().split()) if n % 3 != 0: print('no') contin...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 9; int main() { int T; cin >> T; long long N, K, D1, D2, a, b, c; while (T--) { cin >> N >> K >> D1 >> D2; long long med = N; if (N % 3 != 0) cout << "no" << endl; else { bool f = 0; a = 2 * D1 + D2 + K; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
//import com.sun.org.apache.xpath.internal.operations.String; import java.io.*; import java.util.*; public class scratch_25 { // int count=0; //static long count=0; static class Reader { static BufferedReader reader; static StringTokenizer tokenizer; /** * call this metho...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
def cal(x,y): return x*y def cal_equation(a,b,c,n): total = a + b + c if total >= 0 and total % 3 == 0 and total <= n: return 1 return 0 alist = [[1,0,1],[1,0,-1],[-1,0,1],[-1,0,-1]] n = int(raw_input()) for i in range(0,n): a = map(int, raw_input().split()) b = [a[2],0,a[3]] ok = F...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> long long val(long long *a, long long *b, long long *c, long long k, long long d1, long long d2) { *c = k - (d1 + 2 * d2); if (*c % 3 != 0) return 0; *c /= 3; *b = *c + d2; *a = *c + d1 + d2; } int main() { long long t, a, b, c, n, k, d1, d2, i, j; scanf("%lld", &t);...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class cf258c { private static boolean judge(long n,long k,long d1,long d2) { long[] p1={-d1,d1}; long[] p2={-d2,d2}; long[] a=new long[5]; long sum; for(int i=0;i<=1;i++) { for(int j=0;j<=1;j++) { ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b < a) { long long int temp = a; a = b; b = temp; } if (a == 0) { return b; } return gcd(b % a, a); } long long int lcm(long long int a, long long int b) { return (a * b / gcd(a, b)); } lo...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; public class C{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int d[] = {1,-1}; while(N-->0){ long n = sc.nextLong(); long k = sc.nextLong(); long d1 = sc.nextLong(); long d2 = sc.nextLong(); boolean has = false; for...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2, rem; cin >> n >> k >> d1 >> d2; rem = n - k; if (n % 3 != 0) { cout << "no" << endl; continue; } if (d1 + d2 + d2 <= k && (d1 + d2 + d2) % 3 == k % 3) { long ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputstream = System.in; OutputStream outputstream = System.out; InputReader in = new InputReader(inputstream); OutputWriter out = new OutputWriter(outputstream); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, d1, d2, f1, f2, f3; int t; scanf("%d", &t); while (t--) { scanf("%I64d %I64d %I64d %I64d", &n, &k, &d1, &d2); if (n % 3) { puts("no"); continue; } n /= 3; if ((k + 2 * d1 + d2) % 3 == 0) { f1 = (k + ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputSt...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; int main() { int T; scanf("%d", &T); while (T--) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3 != 0) { puts("no"); continue; } if (k >= max(d1, d2) + abs(d1 - d2) && n - k - d1 - d2 >= 0 && (n ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } const int N = 1e5 + 7; const int xinc[] = {0, 0, 1, -1}; const int yinc[...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.lang.*; import static java.lang.Math.*; import java.lang.reflect.*; import java.math.BigInteger; import static java.math.BigInteger.*; import java.security.CodeSource; import java.security.KeyStore; import java.util.*; import static java.util.Arrays.*; import java.util.jar.JarEntry; import...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long mod = 1e9 + 7; int T; int main() { std::ios::sync_with_stdio(0); ; cin >> T; while (T--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; long long h = n - k; long long t = h; long long a, b, c; b = 0; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); for (long T = in.nextInt(), s, t; T > 0; T--) { long n = in.nextLong(), k = in.nextLong(), p = in.nextLong(), q = in.nextLong(); boolean yes = false; s = p + p + q...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> int main() { long long n; scanf("%lld", &n); while (n--) { long long n, k, d1, d2; scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); long long a = d1 > d2 ? d1 : d2; ; long long b = d1 < d2 ? d1 : d2; ; int flag = 0; if (n - k >= 2 * d1 + d2 && (n - k - 2 * d1 -...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long a, b, c; long long n, k, d1, d2; bool work(int i) { a = n; if (i == 1) { b = a - d1; c = b - d2; } else if (i == 2) { b = a - d1; c = b + d2; } else if (i == 3) { b = a + d1; c = b + d2; } else { b = a + d1; c = b - d2; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k, d1, d2; long long a, b, c; bool check() { if (a >= 0 && a <= n / 3 && b >= 0 && b <= n / 3 && c >= 0 && c <= n / 3) return 1; return 0; } void doing() { cin >> n >> k >> d1 >> d2; double aa; if (n % 3 != 0) { puts("no"); return; } a...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.LinkedList; import java.util.StringTokenizer; public class Main { public static void main(String[]...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class PredictOutcomeoftheGame { static long t; static long n; static long k; static long d1; static long d2; static StringBuilder res = new StringBuild...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool deal(long long a, long long b, long long c, long long n, long long k) { long long Min = min(a, b), nn = n - k; Min = min(Min, c); if (Min < 0) { a -= Min; b -= Min; c -= Min; } long long sum = a + b + c; if (sum > k) return false; k -= sum; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class C { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author sousnake */ public class C { public static void main(String sasa[]) throws IOException{ Buffe...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; import java.util.Map.Entry; public class C { boolean q(long n, long k, long x, long y) { long ccc = k + 2 * y + x; if (ccc < 0 || ccc % 3 != 0) { return false; } long c = ccc / 3; long b = c - y; long a = b - x; if (a < 0 || b < 0) { return false; } ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; import java.io.*; public class PredictOutcomeOfTheGame { public static InputReader in; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out); in...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import fileinput import sys inp = [] for line in fileinput.input(): inp.append(line) #inp = raw_input().split("\n") inp = inp[1:] def solve(test): n = test[0] k = test[1] d1 = test[2] d2 = test[3] if not(n%3 == 0): return "no" each = n/3 for i in [-1,1]: for j in [-1,1]:...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, k, d1, d2, i; cin >> t; for (i = 0; i < t; i++) { cin >> n >> k >> d1 >> d2; if ((k - d1 - d2) >= 0 && (k - d1 - d2) % 3 == 0 && (3 * max(d1, d2) - d1 - d2) <= (n - k) && (n - k - (3 * max(d1, d2) - d1 - d2)) % 3 ==...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int is(long long n, long long k, long long d1, long long d2, long long d3) { if ((d1 + d2 + d3) > k) return 0; if ((k - (d1 + d2 + d3)) % 3) return 0; long long rest = 0; rest = (d3 - d2) + (d3 - d1); if ((k + rest) > (n)) return 0; rest = (n) - (k + rest); if...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int t; long long n, k, d1, d2; int main() { scanf("%d", &t); while (t--) { scanf("%I64d%I64d%I64d%I64d", &n, &k, &d1, &d2); if (n % 3 != 0) { printf("no\n"); } else { bool flag = false; for (int i = 0; i < 4; ++i) { long long t1 = i...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.Scanner; public class C { public static void main(String[] args) { L:for(int t = (int)NI();t>0;t--){ long n = NI(); long k = NI(); long d1 = NI(); long d2 = NI(); if(n%3!=0){ System.out.println("no"); continue; } if(k==0){ System.out.println("yes"); continue; ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); long long n, k, d1, d2, ans, x, y, z; int flag = 0; while (t--) { cin >> n >> k >> d1 >> d2; if ((n % 3) != 0) { cout << "no\n"; continue; } if (n == k) { if (d1 == d2 && d1 == 0) cout ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int gcd(int p, int q) { return q == 0 ? p : gcd(q, p % q); } long long t, n, k, d1, d2; long long x1, x2, x3; bool temp; bool check() { if (x1 >= 0 && x2 >= 0 && x3 >= 0 && x1 <= n / 3 && x2 <= n / 3 && x3 <= n / 3) { return true; } return false; } int main(...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; bool check1(void); bool check2(void); bool check3(void); bool check4(void); long long test, n, k, d1, d2, p, A[4], remain; int main() { ios::sync_with_stdio(0); cin >> test; while (test--) { cin >> n >> k >> d1 >> d2; if (check1() || check2() || check3() || ch...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") bool check(long long foo) { return (foo % 3 == 0 && foo >= 0); } bool isValid(long long n, long long k, long long d1, long...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import stdin def solve(n, k, d1, d2): if (d1 + 2 * d2 + k) % 3 != 0: return False c = (d1 + 2 * d2 + k) // 3 a = c - d1 - d2 b = k - a - c if a >= 0 and b >= 0 and c >= 0 and a + b + c == k: _max = max(a, b, c) diff = sum(_max - e for e in [a, b, c]) d = ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.File; import java.io.FileNotFoundException; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.FileRe...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); for (int cc = 0; cc < t; cc++) { long long n, k, d1, d2; long long a, b, c; cin >> n >> k >> d1 >> d2; bool found = false; for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { long long sub ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; public class Main { public static class pair implements Comparable<pair> { int a; int b; public pair(int pa, int pb) { a = pa; b= pb; } @Override public int compareTo(pair o) { if(this.a < o.a) return -1; if(this.a > o.a) return 1; return Int...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k, d1, d2; cin >> n >> k >> d1 >> d2; if (n % 3 != 0) { cout << "no" << endl; continue; } long long w1, w2, w3; bool flag = true; if (k - 2 * d1 - d2 < 0 || (k - 2 * d1 - ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long t, n, m; bool ok1(long long n, long long k, long long d1, long long d2) { if ((k - d1 - 2 * d2) % 3 != 0) return false; if ((k - d1 - 2 * d2) / 3 < 0 || (k - d1 - 2 * d2) / 3 < 0) return false; n -= k; n -= d1 * 2; n -= d2; if (n >= 0 && (n) % 3 == 0) ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; } in...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long n, k; bool f(long long x, long long y, long long z) { if ((k - x - y - z) < 0 || (k - x - y - z) % 3 != 0) return false; long long m = max(x, max(y, z)), p = n - (k + 3 * m - (x + y + z)); if (p < 0 || p % 3 != 0) return false; return true; } int main() { ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; struct node { long long int f, g, h; }; long long int n, k, d1, d2; struct node fun1(long long int a, long long int b) { struct node s; s.g = k - a - b; s.g /= 3; s.f = a + s.g; s.h = b + s.g; return s; } struct node fun2(long long int a, long long int b) { ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class PredictOutcomeOfTheGame { static int [] sign1=new int[]{1,1,-1,-1}; static int [] sign2=new int[]{1,-1,1,-1}; public static void main(String[] args) throws Exception { // TOD...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int t; long long n, k, d1, d2; int main() { scanf("%I64d", &t); for (int i = 0; i < t; i++) { scanf("%I64d %I64d %I64d %I64d", &n, &k, &d1, &d2); if ((k >= 2 * d2 + d1 && (k - 2 * d2 - d1) % 3 == 0) && ((n - k >= 2 * d1 + d2) && ((n - k - 2 * d1 - d2) % ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class a { public static void main(String[] args) { Scanner s = new Scanner(System.in); long q = s.nextLong(); while(q>0){ long n=s.nextLong(); long k=s.nextLon...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int T; long long n, k, d1, d2; long long x1, x2, x3; bool good() { x1 = (k + d1 + d2) / 3; x2 = x1 - d1; x3 = x1 - d2; return (k + d1 + d2) % 3 == 0 && min(min(x1, x2), x3) >= 0 && max(max(x1, x2), x3) <= n / 3; } int main() { scanf("%d", &T); for (int ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class PredictOutcomeoftheGame { public static void main(String[] args) throws IOException { Init(System.in); int t = nextInt(); long n, k, d1, d2; ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; long long mod = 1e9 + 7; double eps = 1e-9; double pi = acos(-1); long long fastpower(long long b, long long p) { double ans = 1; while (p) { if (p % 2) { ans = (ans * b); } b = b * b; p /= 2; } return ans; } bool val...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; long long n, k, d1, d2; cin >> t; while (t--) { scanf("%I64d %I64d %I64d %I64d", &n, &k, &d1, &d2); if (n % 3) { cout << "no" << endl; continue; } int f = 0; long long tt = n / 3; long long x, y, z; if ((k ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> int main() { int T; scanf("%d", &T); while (T--) { long long n, k, d1, d2; scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); if (n % 3) { printf("no\n"); continue; } n /= 3; if ((k - d1 - d2) % 3 == 0) { long long a = (k - d1 - d2) / 3; if (a <= ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
from sys import stdin def solve(n, k, d1, d2): if (d1 + 2 * d2 + k) % 3 != 0: return False c = (d1 + 2 * d2 + k) // 3 a = c - d1 - d2 b = k - a - c if a >= 0 and b >= 0 and c >= 0: _max = max(a, b, c) diff = sum(_max - e for e in [a, b, c]) d = n - k if d ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; public class C451 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sca=new Scanner(System.in); int t=sca.nextInt(); for(int i=1;i<=t;i++){ long n=sca.nextLong(); long k=sca.nextLong(); long ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long int n, k; bool check(vector<long long int> a) { sort(a.rbegin(), a.rend()); long long int tmp = min(a[1], a[2]); if (tmp < 0) { for (int i = 0; i < (int)(a.size()); i++) a[i] -= tmp; } long long int ret = 0; for (int i = 0; i < (int)(3); i++) ret +...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import sys import operator input = sys.stdin.readline def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): """ n, k, d1, d2 d1 = abs(w1-w2) d2 = abs(w2-w3) w1+w2+w3=k 1) w1 >= w2 and w2 >= w3 d1 = w1-w2 ...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int solveFaster(long long n, long long k, long long d1, long long d2) { if (n % 3 != 0) { return 0; } for (int sign1 = -1; sign1 <= 1; sign1++) { for (int sign2 = -1; sign2 <= 1; sign2++) { if (sign1 == 0 || sign2 == 0) { continue; } ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 1000000007L; static final int INF = 50000000; public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); int Q = sc.ni(); for (int q = 0...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 100050; int t; long long n, k, d1, d2; bool ok(long long x1, long long x2, long long x3) { long long val; if (abs(x1 - x2) != d1 || abs(x2 - x3) != d2) while (1) ; while (x1 < 0 || x2 < 0 || x3 < 0) { val = (x1 < 0 ? -x1 : (x2 < 0 ? -x2 : -...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
def test(n,k,d1,d2): f=min(0,d2,d1+d2) if k<2*d2+d1-3*f: return False if (k-d1-2*d2)%3!=0: return False r=n-k if (r+d1-d2)%3!=0: return False if min(r+d1-d2,r-d2-2*d1,r+d1+2*d2)<0: return False return True for _ in range(input()): n,k,d1,d2=map(int,raw_inp...
PYTHON
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.util.*; import java.io.*; import java.math.*; import java.lang.reflect.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(out...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; void solution(); stack<clock_t> times; void start_t() { times.push(clock()); } void stop_t(string out) { clock_t now = clock(); clock_t past = times.top(); times.pop(); double delta = now - past; cout << out << ": " << fixed << delta / (double)CLOCKS_PER_SEC << en...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int tests; long long n, k, d1, d2; void read() { cin >> tests; } void solve() { while (tests--) { cin >> n >> k >> d1 >> d2; long long left, a, b, c, x, diff; if (tests == 99943) { } if (n % 3 != 0) goto _next; x = k + d2 - d1; if (x >= 0 && x ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.lang.*; import java.util.*; import java.text.*; public class Main { static int[][] poss={{1,1},{1,-1},{-1,1},{-1,-1}}; public static void main(String[] args) throws IOException { //BufferedReader cin = new BufferedReader(new FileReader("te.txt")); BufferedReader cin = new Buffe...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = 1e9, mod = 1e9 + 7, N = 3e5; const long long linf = 1e18; bool check(long long n, long long k, long long a, long long b, long long c) { if (a < 0 || b < 0 || c < 0) return false; long long mn = min(min(a, b), c); a -= mn; b -= mn; c -= mn; long l...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.*; import java.util.*; public class SolutionC { public void solve(){ int t = nextInt(); for (int i = 0; i < t; i++) { long n = nextLong(), k = nextLong(), d1 = nextLong(), d2= nextLong(); if(n%3 != 0 ){ out.println("no"); ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; import static java.lang.Math.min; import static java.lang.Math.max; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new Fil...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.ObjectInputStream.GetField; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; ...
JAVA
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; long long dist[3][3]; int id[3]; int main() { memset(dist, -1, sizeof dist); int tcase; long long n, k, d1, d2; scanf("%d", &tcase); while (tcase--) { scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); long long remain = n - k; dist[1][0] = dist[0][1] = d1; ...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int i, j, t, tt, ii, jj; long long n, k, p, k1, need, d1, d2, x1, x2, x3, mid, min, max; bool flag; scanf("%d", &tt); for (t = 1; t <= tt; t++) { cin >> n >> k >> d1 >> d2; flag = false; for (i = 1; i <= 2; i++) for (j = 1; j <= 2; j...
CPP
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
t = int(input()) ret = [] while t>0: t-=1 n,k,d1,d2 = map(int,input().split()) # ans = [] y1 = (k-(d1-d2))//3 x1 = y1+d1 z1 = y1-d2 # ans = [y1,z1,x1] # ans = sorted(ans) # ans1 = 2*ans[2]-(ans[0]+ans[1]) ans1 = 2*x1-(z1+y1) if x1+y1+z1==k and min(z1,y1)>=0 and ans1<=n-k an...
PYTHON3
451_C. Predict Outcome of the Game
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each...
2
9
#include <bits/stdc++.h> using namespace std; const long long INFLL = (1LL << 62); const int INF = (1 << 30), MOD = (int)1e9 + 7; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int q; cin >> q; while (q--) { long long n, k, a, b; cin >> n >> k; cin >> a >> b; for (int i = ...
CPP