题解
【基础】邮票
1 条题解
-
0
#include<bits/stdc++.h> using namespace std; int n, t, c, a[100005]; //每次交替取走两张相邻牌(一奇一偶) //留下的是小明的,小明取走尽量小,小李取走尽量大 //因为邮票是奇数,剩余的一定是奇数的中间牌 int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> t; if (i % 2 == 1) {//奇数张 a[++c] = t; //统计奇数位置的排牌 } } sort(a + 1, a + c + 1); cout << a[c/2+1] << endl;//奇数张牌中间的那张 return 0; }
- 1