Submission #877127

# Submission time Handle Problem Language Result Execution time Memory
877127 2023-11-22T22:49:54 Z Marco_Escandon JJOOII 2 (JOI20_ho_t2) C++11
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef pair <int,int> P;

int ans[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	vector <int> A;
	vector <P> B;
	for(int i=0;i<n+1;i++)
	{
		int b;
		scanf("%d",&b);
		B.push_back(P(b,i));
	}
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	multiset <int> st;
	multiset <int>::iterator it;
	for(int i=0;i<n;i++)
	{
		int d=max(0,B[i+1].first-A[i]);
		st.insert(d);
	}
	for(int i=0;i<=n;i++)
	{
		it=st.end();it--;
		ans[B[i].second]=*it;
		if(i==n) break;
		int d=max(0,B[i+1].first-A[i]);
		it=st.lower_bound(d);
		st.erase(it);
		d=max(0,B[i].first-A[i]);
		st.insert(d);
	}
	for(int i=0;i<=n;i++)
	{
		if(i!=0) printf(" ");
		printf("%d",ans[i]);
	}puts("");
	return 0;
}
	

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
ho_t2.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d",&b);
      |   ~~~~~^~~~~~~~~
ho_t2.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d",&a);
      |   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -