Submission #244232

# Submission time Handle Problem Language Result Execution time Memory
244232 2020-07-03T07:56:03 Z WhipppedCream Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
5 ms 256 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 1e5+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

ii arr[maxn];

int b[maxn];

int cur[maxn];

multiset<int> bst;

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i<= n+1; i++)
	{
		scanf("%d", &arr[i].f);
		arr[i].s = i;
	}
	sort(arr+1, arr+n+1);
	for(int i = 1; i<= n; i++)
	{
		scanf("%d", &b[i]);
	}
	sort(b+1, b+n+1);

	for(int i = 2; i<= n+1; i++)
	{
		cur[i-1] = arr[i].f;
		bst.insert(cur[i-1]-b[i-1]);
	}

	printf("%d\n", *(--bst.end()));
	for(int i = 1; i<= n; i++)
	{
		bst.erase(bst.find(cur[i]-b[i]));
		cur[i] = arr[i].f;
		bst.insert(cur[i]-b[i]);
		printf("%d\n", *(--bst.end()));
	}
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
ho_t1.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &arr[i].f);
   ~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &b[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -