2021团体程序设计天梯赛 L1-7 天梯赛的善良
思路:
水题,略过
Tip:
无
#include <bits/stdc++.h> using namespace std; int main() { int maxx = -1, minn = 0x3f3f3f3f; int cntmax = 0, cntmin = 0; int n; cin >> n; for (int i = 1; i <= n; i++) { int a; cin >> a; if (a > maxx) { maxx = a; cntmax = 1; } else if (a == maxx) { cntmax++; } if (a < minn) { minn = a; cntmin = 1; } else if (a == minn) { cntmin++; } } cout << minn << " " << cntmin << endl; cout << maxx << " " << cntmax << endl; return 0; }