时间太复杂了

P1168 中位数

请不要用markdown强调头文件的重要性
by 下划线__ @ 2019-11-16 12:26:44


```cpp #include <bits/stdc++.h> using namespace std; int i; bool cmp(long long a, long long b) { return a < b; } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); long long a[100005]; long long x[100005]; int n; memset(x, 0, sizeof(x)); cin >> n; for(i = 1; i <= n; i++) { cin >> a[i]; } if(n% 2 == 1) { for(i = 1; i <= n; i++) { x[i] = a[i]; } for(i = 1; i <= n; i += 2) { sort(x + 1, x + i, cmp); cout << x[(1 + i) / 2] <<endl; for(int j = 1; j <= n; j++) { x[j] = a[j]; } } } if(n % 2 == 0) { for(i = 1; i <= n; i++) { x[i] = a[i]; } for(i = 1; i <= n - 1; i+=2) { sort(x + 1, x + i, cmp); cout << x[(1 + i) / 2] << endl; for(int j = 1; j <= n; j++) { x[j] = a[j]; } } } return 0; } ```
by D447H @ 2020-02-27 14:03:11


|