Submission #918748

# Submission time Handle Problem Language Result Execution time Memory
918748 2024-01-30T11:03:22 Z Aiperiii Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
396 ms 32596 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
   ios_base::sync_with_stdio();
   cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   vector <int> a(n+1),b(n),v(n+1);
   for(int i=0;i<=n;i++){
      cin>>a[i];v[i]=a[i];
   }
   for(int i=0;i<n;i++)cin>>b[i];

   sort(all(b));sort(all(a));
   multiset <int> ms;
   for(int i=0;i<n;i++){
      ms.insert(max(0ll,a[i]-b[i]));
   }
   map <int,int> ans;
   ans[a.back()]=*ms.rbegin();
   for(int i=n;i>=1;i--){
      ms.erase(ms.find(max(0ll,a[i-1]-b[i-1])));
      ms.insert(max(0ll,a[i]-b[i-1]));
      ans[a[i-1]]=*ms.rbegin();
   }
   for(int i=0;i<=n;i++){
      cout<<ans[v[i]]<<" ";
   }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 3 ms 600 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 2 ms 600 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 3 ms 600 KB Output is correct
28 Correct 3 ms 600 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 3 ms 600 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 3 ms 600 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 2 ms 600 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 3 ms 600 KB Output is correct
28 Correct 3 ms 600 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 3 ms 600 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 321 ms 27428 KB Output is correct
34 Correct 348 ms 32052 KB Output is correct
35 Correct 322 ms 31056 KB Output is correct
36 Correct 345 ms 31832 KB Output is correct
37 Correct 351 ms 32596 KB Output is correct
38 Correct 340 ms 32420 KB Output is correct
39 Correct 354 ms 31056 KB Output is correct
40 Correct 358 ms 31028 KB Output is correct
41 Correct 347 ms 31252 KB Output is correct
42 Correct 350 ms 31320 KB Output is correct
43 Correct 366 ms 30936 KB Output is correct
44 Correct 322 ms 30332 KB Output is correct
45 Correct 317 ms 30468 KB Output is correct
46 Correct 327 ms 30288 KB Output is correct
47 Correct 213 ms 21592 KB Output is correct
48 Correct 236 ms 21584 KB Output is correct
49 Correct 396 ms 32044 KB Output is correct
50 Correct 382 ms 32080 KB Output is correct
51 Correct 361 ms 31828 KB Output is correct
52 Correct 352 ms 32080 KB Output is correct
53 Correct 393 ms 31936 KB Output is correct