Submission #3268954
Source Code Expand
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)
#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)
#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
int main() {
int N;
vector<int> nums, c_nums;
cin1(N);
int n;
rep(i,N) {
scnd1(n);
nums.push_back(n);
c_nums.push_back(n);
}
sort( c_nums.begin(), c_nums.end());
int a = c_nums[N/2-1], b = c_nums[N/2];
if ( a != b) {
rep(i,N) {
if ( nums[i] <= a ) {
prtd1(b);
} else {
prtd1(a);
}
}
} else {
rep(i,N) {
prtd1(a);
}
}
}
Submission Info
Submission Time
2018-09-25 16:48:51+0900
Task
C - Many Medians
User
mensan_fukuhara
Language
C++14 (GCC 5.4.1)
Score
300
Code Size
1934 Byte
Status
AC
Exec Time
57 ms
Memory
3948 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:46:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scnd1(n);
^
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
53 ms
3820 KB
11.txt
AC
44 ms
3564 KB
12.txt
AC
33 ms
2924 KB
2.txt
AC
28 ms
2164 KB
3.txt
AC
54 ms
3820 KB
4.txt
AC
53 ms
3692 KB
5.txt
AC
56 ms
3948 KB
6.txt
AC
53 ms
3820 KB
7.txt
AC
43 ms
3052 KB
8.txt
AC
53 ms
3820 KB
9.txt
AC
57 ms
3948 KB
sample1.txt
AC
1 ms
256 KB
sample2.txt
AC
1 ms
256 KB
sample3.txt
AC
1 ms
256 KB