Submission #259466

# Submission time Handle Problem Language Result Execution time Memory
259466 2020-08-07T21:47:31 Z ChrisT Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main () {
	int n;
	scanf ("%d",&n);
	vector<pii> v(n+1); vector<int> ans(n+1), a(n);
	for (int i = 0; i <= n; i++) scanf ("%d",&v[i].first), v[i].second = i;
	sort(v.begin(),v.end());
	for (auto &au : a) scanf ("%d",&au);
	sort(a.begin(),a.end());
	vector<int> pma(n), sma(n);
	pma[0] = max(0,v[0].first - a[0]);
	for (int i = 0; i < n; i++) pma[i] = max(pma[i-1],v[i].first - a[i]);
	sma[n-1] = max(0,a[n-1] - v[n].first);
	for (int i = n-2; i >= 0; i--) sma[i] = max(sma[i+1],v[i+1].first - a[i]);
	for (int i = 0; i <= n; i++) {
		ans[v[i].second] = max(i ? pma[i-1] : 0,sma[i]);
	}
	for (int i = 0; i <= n; i++) printf ("%d%c",ans[i]," \n"[i==n]);
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d",&n);
  ~~~~~~^~~~~~~~~
ho_t1.cpp:9:55: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i <= n; i++) scanf ("%d",&v[i].first), v[i].second = i;
                               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (auto &au : a) scanf ("%d",&au);
                     ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -