답안 #781567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781567 2023-07-13T08:10:17 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
195 ms 18636 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 

#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,a[li],k,flag,t,cevap[li];
int cev;
pair<int,int> b[li];
string s;
vector<int> v;

inline int in(){
	int x;
	scanf("%d",&x);
	return x;
}

int main(void){
	n=in();
	for(int i=1;i<=n+1;i++){
		b[i].fi=in();
		b[i].se=i;
	}
	FOR a[i]=in();
	sort(a+1,a+n+1);
	sort(b+1,b+n+2);
	multiset<int> st;
	for(int i=1;i<=n;i++){
		st.insert(max(0,b[i].fi-a[i]));
	}
	auto it=st.end();
	it--;
	cevap[b[n+1].se]=*it;
	for(int i=n;i>=1;i--){
		st.erase(st.find(max(0,b[i].fi-a[i])));
		st.insert(max(0,b[i+1].fi-a[i]));
		it=st.end();
		it--;
		cevap[b[i].se]=*it;
	}
	for(int i=1;i<=n+1;i++)printf("%d ",cevap[i]);
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int in()':
ho_t1.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d",&x);
      |  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 448 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 448 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 448 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 448 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 444 KB Output is correct
31 Correct 2 ms 448 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 448 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 448 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 448 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 448 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 444 KB Output is correct
31 Correct 2 ms 448 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 169 ms 17404 KB Output is correct
34 Correct 160 ms 18144 KB Output is correct
35 Correct 137 ms 17456 KB Output is correct
36 Correct 158 ms 18004 KB Output is correct
37 Correct 149 ms 18636 KB Output is correct
38 Correct 147 ms 18412 KB Output is correct
39 Correct 164 ms 17332 KB Output is correct
40 Correct 170 ms 17300 KB Output is correct
41 Correct 164 ms 17536 KB Output is correct
42 Correct 164 ms 17428 KB Output is correct
43 Correct 161 ms 17420 KB Output is correct
44 Correct 136 ms 16808 KB Output is correct
45 Correct 138 ms 16844 KB Output is correct
46 Correct 135 ms 16804 KB Output is correct
47 Correct 128 ms 17244 KB Output is correct
48 Correct 135 ms 17284 KB Output is correct
49 Correct 168 ms 17868 KB Output is correct
50 Correct 195 ms 17808 KB Output is correct
51 Correct 179 ms 17776 KB Output is correct
52 Correct 173 ms 17772 KB Output is correct
53 Correct 167 ms 17868 KB Output is correct