Submission #540496

# Submission time Handle Problem Language Result Execution time Memory
540496 2022-03-20T14:04:58 Z krit3379 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
233 ms 18564 KB
#include<bits/stdc++.h>
using namespace std;
#define N 200005

int b[N],ans[N];
pair<int,int> a[N];
multiset<int> s;

int main(){
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n+1;i++)scanf("%d",&a[i].first),a[i].second=i;
    for(i=1;i<=n;i++)scanf("%d",&b[i]);
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    for(i=1;i<=n;i++)s.insert(-max(a[i].first-b[i],0));
    ans[a[n+1].second]=-*s.begin();
    for(i=n;i>0;i--){
        s.erase(-max(a[i].first-b[i],0));
        s.insert(-max(a[i+1].first-b[i],0));
        ans[a[i].second]=-*s.begin();
    }
    for(i=1;i<=n+1;i++)printf("%d ",ans[i]);
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
ho_t1.cpp:12:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(i=1;i<=n+1;i++)scanf("%d",&a[i].first),a[i].second=i;
      |                        ~~~~~^~~~~~~~~~~~~~~~~~
ho_t1.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%d",&b[i]);
      |                      ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 448 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 476 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 452 KB Output is correct
29 Correct 2 ms 440 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 448 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 476 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 452 KB Output is correct
29 Correct 2 ms 440 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 176 ms 17320 KB Output is correct
34 Correct 199 ms 18092 KB Output is correct
35 Correct 169 ms 17520 KB Output is correct
36 Correct 210 ms 18044 KB Output is correct
37 Correct 194 ms 18564 KB Output is correct
38 Correct 189 ms 18360 KB Output is correct
39 Correct 207 ms 17484 KB Output is correct
40 Correct 216 ms 17300 KB Output is correct
41 Correct 227 ms 17576 KB Output is correct
42 Correct 208 ms 17428 KB Output is correct
43 Correct 210 ms 17204 KB Output is correct
44 Correct 159 ms 16796 KB Output is correct
45 Correct 168 ms 17000 KB Output is correct
46 Correct 161 ms 16684 KB Output is correct
47 Correct 144 ms 17276 KB Output is correct
48 Correct 145 ms 17172 KB Output is correct
49 Correct 214 ms 17840 KB Output is correct
50 Correct 233 ms 17840 KB Output is correct
51 Correct 217 ms 17824 KB Output is correct
52 Correct 211 ms 17828 KB Output is correct
53 Correct 211 ms 17856 KB Output is correct