답안 #629169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629169 2022-08-14T08:42:29 Z iomoon191 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
106 ms 15476 KB
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a).size()
#define pb push_back
#define fi first
#define se second
#define For(i,a,b) for(int i=(a); i<=(b); ++i)
#define roF(i,a,b) for(int i=(a); i>=(b); --i)
using namespace std;
#ifdef DEBUG__
void dmpr(ostream &os){ os << "\n"; }
template<class T, class... Args>
void dmpr(ostream &os, const T &t, const Args &... args){
	os << t << " ";
	dmpr(os, args...);
}
#define dbg(...) dmpr(cerr, __LINE__, ##__VA_ARGS__)
#else
#define dbg(...) void(0)
#endif
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef long double ld;
const int N=200005;
const int inf=0x3f3f3f3f;
mt19937 rng(random_device {}()); 
int rand(int a){
	return rng()%a;
}
int n, b[N], pref[N], suf[N], res[N];
pi a[N];
void rmain(){
	cin >> n;
	For(i,1,n+1){
		cin >> a[i].fi; a[i].se=i;
	}
	For(i,1,n) cin >> b[i];
	sort(a+1, a+n+2);
	sort(b+1, b+n+1);
	For(i,1,n) pref[i]=max(pref[i-1], a[i].fi-b[i]);
	roF(i,n,1) suf[i]=max(suf[i+1], a[i+1].fi-b[i]);
	For(i,1,n+1) res[a[i].se]=max(pref[i-1], suf[i]);
	For(i,1,n+1) cout << res[i] << " ";
}
signed main(int argc, char *argv[]){
	iostream::sync_with_stdio(0);
	int T=1; 
	while(T--) rmain();
	return 0;
}

Compilation message

ho_t1.cpp:47:8: warning: first argument of 'int main(long long int, char**)' should be 'int' [-Wmain]
   47 | signed main(int argc, char *argv[]){
      |        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 92 ms 11300 KB Output is correct
34 Correct 86 ms 15032 KB Output is correct
35 Correct 82 ms 14544 KB Output is correct
36 Correct 106 ms 15136 KB Output is correct
37 Correct 85 ms 15476 KB Output is correct
38 Correct 87 ms 15276 KB Output is correct
39 Correct 91 ms 14348 KB Output is correct
40 Correct 83 ms 14284 KB Output is correct
41 Correct 84 ms 14460 KB Output is correct
42 Correct 86 ms 14404 KB Output is correct
43 Correct 94 ms 14348 KB Output is correct
44 Correct 80 ms 13844 KB Output is correct
45 Correct 86 ms 13960 KB Output is correct
46 Correct 83 ms 13788 KB Output is correct
47 Correct 101 ms 14108 KB Output is correct
48 Correct 80 ms 14068 KB Output is correct
49 Correct 89 ms 14688 KB Output is correct
50 Correct 90 ms 14632 KB Output is correct
51 Correct 99 ms 14632 KB Output is correct
52 Correct 86 ms 14664 KB Output is correct
53 Correct 89 ms 14668 KB Output is correct