Submission #219562

# Submission time Handle Problem Language Result Execution time Memory
219562 2020-04-05T15:03:42 Z MKopchev Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
191 ms 10876 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e5+42;
int n,other[nmax];
pair<int,int> inp[nmax];

int pref[nmax],suff[nmax];

int output[nmax];
int main()
{
    scanf("%i",&n);
    for(int i=1;i<=n+1;i++){scanf("%i",&inp[i]);inp[i].second=i;}
    for(int i=1;i<=n;i++)scanf("%i",&other[i]);

    sort(inp+1,inp+n+2);
    sort(other+1,other+n+1);

    for(int i=1;i<=n;i++)
        pref[i]=max(pref[i-1],inp[i].first-other[i]);

    for(int i=n+1;i>=2;i--)
        suff[i]=max(suff[i+1],inp[i].first-other[i-1]);

    for(int i=1;i<=n+1;i++)
        output[inp[i].second]=max(pref[i-1],suff[i+1]);
    /*
    for(int i=1;i<=n;i++)cout<<pref[i]<<" ";cout<<endl;
    for(int i=1;i<=n+1;i++)cout<<suff[i]<<" ";cout<<endl;
    */
    for(int i=1;i<=n+1;i++)
    {
        printf("%i",output[i]);
        if(i==n+1)printf("\n");
        else printf(" ");
    }
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:13:47: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'std::pair<int, int>*' [-Wformat=]
     for(int i=1;i<=n+1;i++){scanf("%i",&inp[i]);inp[i].second=i;}
                                        ~~~~~~~^
ho_t1.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
ho_t1.cpp:13:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n+1;i++){scanf("%i",&inp[i]);inp[i].second=i;}
                             ~~~~~^~~~~~~~~~~~~~
ho_t1.cpp:14:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++)scanf("%i",&other[i]);
                          ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 8 ms 384 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 256 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 384 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 8 ms 384 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 256 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 384 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
33 Correct 144 ms 9976 KB Output is correct
34 Correct 191 ms 10464 KB Output is correct
35 Correct 144 ms 10104 KB Output is correct
36 Correct 141 ms 10608 KB Output is correct
37 Correct 144 ms 10876 KB Output is correct
38 Correct 147 ms 10744 KB Output is correct
39 Correct 141 ms 9848 KB Output is correct
40 Correct 140 ms 9720 KB Output is correct
41 Correct 143 ms 9848 KB Output is correct
42 Correct 144 ms 9848 KB Output is correct
43 Correct 147 ms 9848 KB Output is correct
44 Correct 137 ms 9336 KB Output is correct
45 Correct 138 ms 9464 KB Output is correct
46 Correct 136 ms 9464 KB Output is correct
47 Correct 121 ms 9464 KB Output is correct
48 Correct 126 ms 9468 KB Output is correct
49 Correct 146 ms 10104 KB Output is correct
50 Correct 151 ms 10232 KB Output is correct
51 Correct 143 ms 10104 KB Output is correct
52 Correct 146 ms 10104 KB Output is correct
53 Correct 153 ms 10104 KB Output is correct