Codeforces Round #491 (Div. 2)----A
程序员文章站
2022-06-02 11:52:54
...
大意是,有两个地方A,B 有一部分人去A,一部分去B,一部分两个都去,一部分两个都没去,求两个都没去的人数。
注意,c可以比a,b大,所以,多一条判断即可
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,n;
cin >> a >> b >> c >> n;
int ans = a+b-c;
if (ans - n >= 0 || a < c || b < c) {
cout << -1 << endl;
}else{
cout << n - ans << endl;
}
return 0;
}
推荐阅读
-
Codeforces Round #595 (Div. 3)D1D2 贪心 STL
-
Codeforces Round #655 (Div. 2) A. Omkar and Completion
-
Codeforces Round #656 (Div. 3)D. a-Good String(递归+dfs)
-
Codeforces Round #487 (Div. 2)
-
CodeForces 1324 - Codeforces Round #627 (Div. 3)
-
Codeforces Round #649 (Div. 2)-B. Most socially-distanced subsequence(思维)
-
Codeforces Round #649 (Div. 2) C-Ehab and Prefix MEXs
-
Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing
-
Codeforces Round #659 (Div. 2) A. Common Prefixes(字符串,思维)
-
Codeforces Round #610 (Div. 2)