제출 #199519

#제출 시각아이디문제언어결과실행 시간메모리
199519ZwariowanyMarcinCipele (COCI18_cipele)C++14
90 / 90
69 ms3216 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define LD long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);


using namespace std;			
	
const int nax = 1e5 + 111;

int n, m, a;
vector <int> x, y;	

bool ok(int dif) {
	int wsk = 0;
	for (int i = 0; i < ss(x); ++i) {
		while (wsk < ss(y) && abs(x[i] - y[wsk]) > dif) wsk++;
		if (wsk == ss(y)) return false;
		wsk++;
	}
	return true;
}
		

int main() {	
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf ("%d", &a);
		x.pb(a);
	}
	for (int i = 1; i <= m; ++i) {
		scanf ("%d", &a);
		y.pb(a);
	}
	
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	
	if (ss(x) > ss(y)) swap(x, y);
	
	int l = 0;
	int r = 1e9 + 11;
	
	while (l < r) {
		int m = (l + r) / 2;
		if (ok(m)) r = m;
		else l = m + 1;
	}
	printf ("%d\n", l);	
	
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

cipele.cpp: In function 'int main()':
cipele.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d", &n, &m);
  ~~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:35:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", &a);
   ~~~~~~^~~~~~~~~~
cipele.cpp:39:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", &a);
   ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...