P9955 [USACO20DEC] Do You Know Your ABCs? B 题解
解析
,
。
和 就是给出的 个数中的最小值和次小值, 就是给出的最大值减去 。
代码
#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 强制终止读入。