Submission #206775

# Submission time Handle Problem Language Result Execution time Memory
206775 2020-03-05T08:24:37 Z Shelby Just Long Neckties (JOI20_ho_t1) C++11
100 / 100
156 ms 8568 KB
#include <bits/stdc++.h>
#define MAXN 200005
using namespace std;

int m[MAXN],s[MAXN],mxm[MAXN],mxs[MAXN],c[MAXN],b[MAXN];
pair<int,int> a[MAXN];

int main()
{ int n,i,poz;
scanf("%d",&n);
for(i=0;i<=n;i++)
{
    scanf("%d",&a[i].first);

    a[i].second=i;
}
for(i=0;i<n;i++) scanf("%d",&b[i]);

sort(a,a+n+1);

sort(b,b+n);

for(i=0;i<n;i++) m[i]=a[i].first-b[i];

for(i=1;i<=n;i++) s[i]=a[i].first-b[i-1];

mxm[0]=m[0];
for(i=1;i<n;i++) mxm[i]=max(mxm[i-1],m[i]);

mxs[n]=s[n];
for(i=n-1;i>0;i--) mxs[i]=max(mxs[i+1],s[i]);

for(i=1;i<n;i++) c[ a[i].second ]=max(mxm[i-1],mxs[i+1]);

c[a[0].second]=mxs[1];  c[a[n].second]=mxm[n-1];

for(i=0;i<=n;i++) printf("%d ",c[i]);
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:9:11: warning: unused variable 'poz' [-Wunused-variable]
 { int n,i,poz;
           ^~~
ho_t1.cpp:10:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&n);
 ~~~~~^~~~~~~~~
ho_t1.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&a[i].first);
     ~~~~~^~~~~~~~~~~~~~~~~~
ho_t1.cpp:17:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 for(i=0;i<n;i++) scanf("%d",&b[i]);
                  ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 248 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 248 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Correct 131 ms 7800 KB Output is correct
34 Correct 142 ms 8184 KB Output is correct
35 Correct 144 ms 8056 KB Output is correct
36 Correct 134 ms 8312 KB Output is correct
37 Correct 141 ms 8568 KB Output is correct
38 Correct 140 ms 8568 KB Output is correct
39 Correct 135 ms 7672 KB Output is correct
40 Correct 143 ms 7544 KB Output is correct
41 Correct 137 ms 7672 KB Output is correct
42 Correct 156 ms 7616 KB Output is correct
43 Correct 136 ms 7672 KB Output is correct
44 Correct 136 ms 7160 KB Output is correct
45 Correct 136 ms 7288 KB Output is correct
46 Correct 134 ms 7160 KB Output is correct
47 Correct 120 ms 7160 KB Output is correct
48 Correct 124 ms 7288 KB Output is correct
49 Correct 146 ms 7800 KB Output is correct
50 Correct 141 ms 7800 KB Output is correct
51 Correct 144 ms 7800 KB Output is correct
52 Correct 140 ms 7800 KB Output is correct
53 Correct 140 ms 7800 KB Output is correct