Submission #3195818
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <iomanip> #include <map> #include <queue> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 2 - 170; int main() { int n; cin >> n; vector<int> v, v2; for (int i = 0; i < n; ++i) { int k; scanf("%d", &k); v.emplace_back(k); v2.emplace_back(k); } sort(v.begin(), v.end()); if(v[n/2] != v[n/2-1]) for (auto &&x : v2) { if(lower_bound(v.begin(), v.end(), x)-v.begin() < n/2){ cout << v[n/2] << "\n"; }else { cout << v[n/2-1] << "\n"; } } else for (int i = 0; i < n; ++i) cout << v[n/2] << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Many Medians |
User | firiexp |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 838 Byte |
Status | AC |
Exec Time | 86 ms |
Memory | 3948 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:22:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &k); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 1 ms | 256 KB |
10.txt | AC | 80 ms | 3820 KB |
11.txt | AC | 47 ms | 3564 KB |
12.txt | AC | 36 ms | 2924 KB |
2.txt | AC | 40 ms | 2164 KB |
3.txt | AC | 82 ms | 3820 KB |
4.txt | AC | 80 ms | 3692 KB |
5.txt | AC | 84 ms | 3948 KB |
6.txt | AC | 80 ms | 3820 KB |
7.txt | AC | 63 ms | 3052 KB |
8.txt | AC | 81 ms | 3820 KB |
9.txt | AC | 86 ms | 3948 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |