Submission #347303

# Submission time Handle Problem Language Result Execution time Memory
347303 2021-01-12T13:55:00 Z CaroLinda Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
416 ms 18668 KB
#include <bits/stdc++.h>

#define ll long long
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x.size() ) 

const int MAXN = 2e5+10 ;

using namespace std ;

int N ;
int C[MAXN] , employees[MAXN] ;
pair<int,int> neckties[MAXN] ;

int main()
{
	scanf("%d", &N) ;
	for(int i = 1 ; i <= N+1 ; i++ ) 
	{
		scanf("%d", &neckties[i].first ) ;
		neckties[i].second = i ;
	}

	sort(neckties+1, neckties + 2 + N ) ;

	for(int i= 1 ; i <= N ; i++ ) scanf("%d", &employees[i] ) ;

	sort(employees+1, employees + 1 + N ) ;

	multiset< int > s ;

	for(int i = 1 ; i <= N ; i++ ) s.insert( -max( neckties[i+1].first - employees[i] , 0 ) )  ;

	for(int i=1 ; i <= N+1 ; i++ )
	{
		C[ neckties[i].second ]	= -*s.begin() ;

		if( i == N+1 ) break ;

		auto it = s.find( -max(neckties[i+1].first - employees[i] , 0 ) ) ;

		s.erase( it ) ;

		s.insert( -max(neckties[i].first - employees[i] , 0 ) ) ;

	}                                                          

	for(int i = 1 ; i <= N+1 ; i++ ) printf("%d ", C[i] ) ;
	printf("\n") ;

}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d", &N) ;
      |  ~~~~~^~~~~~~~~~
ho_t1.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%d", &neckties[i].first ) ;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:26:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |  for(int i= 1 ; i <= N ; i++ ) scanf("%d", &employees[i] ) ;
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 3 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 4 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 640 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 640 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 3 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 4 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 640 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 640 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
33 Correct 246 ms 17516 KB Output is correct
34 Correct 259 ms 18156 KB Output is correct
35 Correct 226 ms 17644 KB Output is correct
36 Correct 256 ms 18124 KB Output is correct
37 Correct 269 ms 18668 KB Output is correct
38 Correct 253 ms 18412 KB Output is correct
39 Correct 360 ms 17516 KB Output is correct
40 Correct 359 ms 17420 KB Output is correct
41 Correct 376 ms 17612 KB Output is correct
42 Correct 368 ms 17516 KB Output is correct
43 Correct 340 ms 17420 KB Output is correct
44 Correct 203 ms 16876 KB Output is correct
45 Correct 209 ms 17004 KB Output is correct
46 Correct 203 ms 16876 KB Output is correct
47 Correct 200 ms 17260 KB Output is correct
48 Correct 215 ms 17260 KB Output is correct
49 Correct 376 ms 18028 KB Output is correct
50 Correct 392 ms 18008 KB Output is correct
51 Correct 416 ms 17900 KB Output is correct
52 Correct 376 ms 18028 KB Output is correct
53 Correct 355 ms 18060 KB Output is correct