Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
104707 彭士宝 寻找第二小的数 C++ Wrong Answer 0 MS 272 KB 763 2025-01-08 20:21:27

Tests(0/1):


Code:

#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int C; cin >> C; // 读取测试数据的组数 while (C--) { int n; cin >> n; // 读取每组测试数据的整数个数 vector<int> numbers(n); for (int i = 0; i < n; ++i) { cin >> numbers[i]; // 读取每个整数 } // 对整数进行排序 sort(numbers.begin(), numbers.end()); // 寻找第二小的数,如果所有数都相同,则输出 "NO" if (n == 1 || numbers[0] == numbers[1]) { cout << "NO" << endl; } else { cout << numbers[1] << endl; // 输出第二小的数 } } return 0; }


Run Info:

------Input------
10 10 9 80 70 60 60 1 9 9 1 1 2 1 1 2 90 99 5 2 2 2 2 2 8 0 -1 -1 1 2 3 4 5 10 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 2 -4 -9 2 -0 0 2 -0 8 7 -0 0 0 -0 0 0 9
------Answer-----
9 NO 99 NO 0 NO -4 NO 8 9
------Your output-----
NO NO 99 NO NO NO -4 NO 8 NO