답안 #243122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243122 2020-06-30T11:29:35 Z socho Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
5 ms 384 KB
#include "bits/stdc++.h"
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b; 
}
// #define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {
	
	ran(); fast();
	
	int n;
	cin >> n;
	
	pair<int, int> ops[n+1];
	for (int i=0; i<n+1; i++) {
		cin >> ops[i].first;
		ops[i].second = i;
	}
	int arr[n];
	for (int i=0; i<n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr+n);
	sort(ops, ops+n+1);
	
	multiset<int> dfs;
	for (int i=1; i<n+1; i++) {
		dfs.insert(abs(ops[i].first - arr[i-1]));
	}
	
	int ans[n+1];
	ans[ops[0].second] = *(--dfs.end());
	
	for (int i=1; i<n+1; i++) {
		dfs.erase(dfs.find(abs(ops[i].first - arr[i-1])));
		dfs.insert(abs(ops[i-1].first - arr[i-1]));
		ans[ops[i].second] = *(--dfs.end());
	}
	
	for (int i=0; i<n+1; i++) {
		cout << ans[i] << ' ';
	}
	cout << endl;
	
}
	

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:32:6: warning: argument 1 range [18446744065119617024, 18446744073709551612] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  int arr[n];
      ^~~
ho_t1.cpp:32:6: note: in a call to built-in allocation function 'void* __builtin_alloca_with_align(long unsigned int, long unsigned int)'
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -