# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
228487 | 2020-05-01T08:02:56 Z | Ruxandra985 | Just Long Neckties (JOI20_ho_t1) | C++14 | 161 ms | 13276 KB |
#include <bits/stdc++.h> #define DIMN 200010 using namespace std; pair <int,int> v[DIMN]; int w[DIMN]; priority_queue <pair <int,int> > h; int val[DIMN] , sol[DIMN]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , i , x , idx; fscanf (fin,"%d",&n); for (i = 1 ; i <= n + 1 ; i++){ fscanf (fin,"%d",&v[i].first); v[i].second = i; } for (i = 1 ; i <= n ; i++){ fscanf (fin,"%d",&w[i]); } sort (w + 1 , w + n + 1); sort (v + 1 , v + n + 2); /// o sa cuplezi al i lea din w cu al i + 1 lea din v for (i = 1 ; i <= n ; i++){ h.push(make_pair(max(0 , v[i].first - w[i]) , i)); val[i] = max(0 , v[i].first - w[i]); } /// asta ar fi solutia pt cand elimini v[1].second sol[v[n+1].second] = h.top().first; for (i = n ; i ; i--){ val[i] = max(0 , v[i + 1].first - w[i]); h.push(make_pair(val[i] , i)); /// pe v[i + 1].second il stergi x = h.top().first; idx = h.top().second; while (val[idx] != x){ h.pop(); x = h.top().first; idx = h.top().second; } sol[v[i].second] = h.top().first; } for (i = 1 ; i <= n + 1 ; i++) fprintf (fout,"%d " , sol[i] ); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 512 KB | Output is correct |
15 | Correct | 5 ms | 512 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 8 ms | 512 KB | Output is correct |
18 | Correct | 6 ms | 512 KB | Output is correct |
19 | Correct | 6 ms | 512 KB | Output is correct |
20 | Correct | 6 ms | 512 KB | Output is correct |
21 | Correct | 6 ms | 512 KB | Output is correct |
22 | Correct | 6 ms | 512 KB | Output is correct |
23 | Correct | 6 ms | 512 KB | Output is correct |
24 | Correct | 6 ms | 512 KB | Output is correct |
25 | Correct | 6 ms | 512 KB | Output is correct |
26 | Correct | 6 ms | 512 KB | Output is correct |
27 | Correct | 6 ms | 512 KB | Output is correct |
28 | Correct | 6 ms | 512 KB | Output is correct |
29 | Correct | 6 ms | 512 KB | Output is correct |
30 | Correct | 7 ms | 512 KB | Output is correct |
31 | Correct | 6 ms | 512 KB | Output is correct |
32 | Correct | 6 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 512 KB | Output is correct |
15 | Correct | 5 ms | 512 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 8 ms | 512 KB | Output is correct |
18 | Correct | 6 ms | 512 KB | Output is correct |
19 | Correct | 6 ms | 512 KB | Output is correct |
20 | Correct | 6 ms | 512 KB | Output is correct |
21 | Correct | 6 ms | 512 KB | Output is correct |
22 | Correct | 6 ms | 512 KB | Output is correct |
23 | Correct | 6 ms | 512 KB | Output is correct |
24 | Correct | 6 ms | 512 KB | Output is correct |
25 | Correct | 6 ms | 512 KB | Output is correct |
26 | Correct | 6 ms | 512 KB | Output is correct |
27 | Correct | 6 ms | 512 KB | Output is correct |
28 | Correct | 6 ms | 512 KB | Output is correct |
29 | Correct | 6 ms | 512 KB | Output is correct |
30 | Correct | 7 ms | 512 KB | Output is correct |
31 | Correct | 6 ms | 512 KB | Output is correct |
32 | Correct | 6 ms | 512 KB | Output is correct |
33 | Correct | 152 ms | 12424 KB | Output is correct |
34 | Correct | 156 ms | 12944 KB | Output is correct |
35 | Correct | 145 ms | 12512 KB | Output is correct |
36 | Correct | 152 ms | 13152 KB | Output is correct |
37 | Correct | 155 ms | 13276 KB | Output is correct |
38 | Correct | 151 ms | 13152 KB | Output is correct |
39 | Correct | 157 ms | 12252 KB | Output is correct |
40 | Correct | 158 ms | 12252 KB | Output is correct |
41 | Correct | 156 ms | 12256 KB | Output is correct |
42 | Correct | 157 ms | 12388 KB | Output is correct |
43 | Correct | 154 ms | 12252 KB | Output is correct |
44 | Correct | 148 ms | 12008 KB | Output is correct |
45 | Correct | 148 ms | 12008 KB | Output is correct |
46 | Correct | 148 ms | 12008 KB | Output is correct |
47 | Correct | 132 ms | 12392 KB | Output is correct |
48 | Correct | 134 ms | 12392 KB | Output is correct |
49 | Correct | 158 ms | 12540 KB | Output is correct |
50 | Correct | 161 ms | 12508 KB | Output is correct |
51 | Correct | 160 ms | 12512 KB | Output is correct |
52 | Correct | 160 ms | 12684 KB | Output is correct |
53 | Correct | 156 ms | 12508 KB | Output is correct |