Codeforces Round #615(Div.3)
Codeforces Round #615(Div.3) A. Collecting Coins 注意(n)可能不够用的情况。 # include <bits/stdc++.h> using namespace std ; # define ll long long const int maxn = 2e5 + 10 ; int main ( ) { ios_base :: sync_with_stdio ( 0 ) ; ll n ; cin >> n ; while ( n -- ) { int a , b , c , n ; cin >> a >> b >> c >> n ; int ma = max ( a , max ( b , c ) ) ; int cnt = abs ( ma - a ) + abs ( ma - b ) + abs ( ma - c ) ; int remain = n - cnt ; if ( remain >= 0 && remain % 3 == 0 ) { cout << "YES" << endl ; } else { cout << "NO" << endl ; } } return 0 ; } B. Collecting Packages 直接模拟这个过程就好了,注意字典序最小的方案。 # include <bits/stdc++.h>