P9955 题解

· · 题解

P9955 [USACO20DEC] Do You Know Your ABCs? B 题解

解析

$\therefore a\leq b\leq \cdots \leq a+b+c$。 $a$ 和 $b$ 就是给出的 $7$ 个数中的最小值和次小值,$c$ 就是给出的最大值减去 $a+b$。 ### 代码 ```cpp #include<bits/stdc++.h> using namespace std; vector<int>v; int tmp; int main(){ cin.tie(0)->sync_with_stdio(0); while(cin>>tmp){ v.push_back(tmp); } sort(v.begin(),v.end()); cout<<v[0]<<" "<<v[1]<<" "<<v[6]-v[0]-v[1]; return 0; } ``` ### 题外话 由于使用了 `while` 读入,在读完数之后请按 `Ctrl+Z` 强制终止读入。