ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#213949 | #2380. 中位数 | Lin_ziluo | Compile Error | / | / | C++ | 510b | 2024-11-14 19:44:06 | 2024-11-14 23:03:53 |
answer
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int a[300010];
int median(vector<int> x){
nth_element(x.begin(),x.begin() + (x.size() + 1) / 2 - 1,x.end());
return x[(x.size() + 1) / 2 - 1];
}
int main(){
int n;
cin >> n;
for (int i = 1;i <= n;i++)
cin >> a[i];
for (int i = 1;i <= n;i++)
for (int j = i;j <= n;j++){
vector<int> t;
for (int k = i;k <= j;k++)
t.emplace_back(a[k]);
v.emplace_back(median(t));
}
cout << median(v) << endl;
return 0;
}
Details
answer.code: In function 'int main()': answer.code:18:7: error: 'class std::vector<int>' has no member named 'emplace_back' t.emplace_back(a[k]);\x0d ^ answer.code:19:6: error: 'class std::vector<int>' has no member named 'emplace_back' v.emplace_back(median(t));\x0d ^