全WA求助,自测过,有时输出0

P4715 【深基16.例1】淘汰赛

@[lwx20211103](/user/727008) ```cpp #include <bits/stdc++.h> using namespace std; struct country { int id; int score; }; country nums[1145]; bool compare(country x, country y) { return x.score > y.score; } int main() { int n = 4, i; cin >> n; n = 1 << n; for (i = 1; i <= n; i++) { cin >> nums[i].score; nums[i].id = i; } sort(nums + 1, nums + n / 2, compare);//数据太水,加上1也过了,但是实际不对 int temp1 = nums[1].score, t1 = nums[1].id; sort(nums + 1 + n / 2, nums + n + 1, compare); int temp2 = nums[n/2+1].score, t2 = nums[n/2+1].id;//你这儿为啥要写5 temp1 > temp2 ? cout << t2 : cout << t1; return 0; } ```
by yizhiming @ 2022-09-02 21:05:16


@[yizhiming](/user/369399) emmm第一个注释好像是我看错了
by yizhiming @ 2022-09-02 21:09:11


|