Submission #364606

# Submission time Handle Problem Language Result Execution time Memory
364606 2021-02-09T13:56:49 Z Killer2501 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
138 ms 19180 KB
#include <bits/stdc++.h>
#define pb push_back
#define task "sequence"
#define pll pair<ll, ll>
#define pii pair<vector<ll>, ll>
#define fi first
#define se second

using ll = long long;
const long long mod = 1e15+7;
const ll mod1 = 1e9+1;
const ll N = 2e5+5;
const int base = 350;
using ull = unsigned long long;
using namespace std;
string s, ss;
ll n, m, t, k, T, cnt, tong, a[N], c[N], b[N], l[N], r[N], d[N];
vector<ll> adj[N], kq;
pll p[N];
bool cmp(const ll& x, const ll& y)
{
    return a[x] < a[y];
}
void sol()
{
    cin >> n;
    for(int i = 1; i <= n+1; i ++)cin >> a[i], c[i] = i;
    for(int i = 1; i <= n; i ++)cin >> b[i];
    sort(b+1, b+1+n);
    sort(c+1, c+1+n+1, cmp);
    for(int i = 1; i <= n; i ++)
    {
        //cout << a[c[i]] <<" "<<b[i]<<'\n';
        d[c[i]] = i;
        l[i] = max(l[i-1], a[c[i]] - b[i]);
    }
    for(int i = n+1; i > 1; i --)
    {
        r[i] = max(r[i+1], a[c[i]] - b[i-1]);
        d[c[i]] = i;
    }
    //for(int i = 1; i <= n+1; i ++)cout << d[i] <<" ";
    for(int i = 1; i <= n+1; i ++)cout << max(l[d[i]-1], r[d[i]+1])<<" ";
}

int main()
{
    if(fopen(task".in", "r")){
       freopen(task".in", "r", stdin);
       freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest;
    ntest =  1;
    //cin >> ntest;
    //cout << (1<<30) << '\n';
    while(ntest -- > 0)
    sol();

}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:49:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   49 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:50:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   50 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5100 KB Output is correct
2 Correct 3 ms 5100 KB Output is correct
3 Correct 3 ms 5100 KB Output is correct
4 Correct 3 ms 5100 KB Output is correct
5 Correct 4 ms 5100 KB Output is correct
6 Correct 3 ms 5100 KB Output is correct
7 Correct 4 ms 5100 KB Output is correct
8 Correct 3 ms 5100 KB Output is correct
9 Correct 4 ms 5100 KB Output is correct
10 Correct 3 ms 5100 KB Output is correct
11 Correct 4 ms 5100 KB Output is correct
12 Correct 4 ms 5100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5100 KB Output is correct
2 Correct 3 ms 5100 KB Output is correct
3 Correct 3 ms 5100 KB Output is correct
4 Correct 3 ms 5100 KB Output is correct
5 Correct 4 ms 5100 KB Output is correct
6 Correct 3 ms 5100 KB Output is correct
7 Correct 4 ms 5100 KB Output is correct
8 Correct 3 ms 5100 KB Output is correct
9 Correct 4 ms 5100 KB Output is correct
10 Correct 3 ms 5100 KB Output is correct
11 Correct 4 ms 5100 KB Output is correct
12 Correct 4 ms 5100 KB Output is correct
13 Correct 4 ms 5100 KB Output is correct
14 Correct 4 ms 5100 KB Output is correct
15 Correct 4 ms 5228 KB Output is correct
16 Correct 4 ms 5100 KB Output is correct
17 Correct 5 ms 5248 KB Output is correct
18 Correct 4 ms 5228 KB Output is correct
19 Correct 4 ms 5228 KB Output is correct
20 Correct 4 ms 5228 KB Output is correct
21 Correct 5 ms 5228 KB Output is correct
22 Correct 5 ms 5228 KB Output is correct
23 Correct 5 ms 5228 KB Output is correct
24 Correct 4 ms 5228 KB Output is correct
25 Correct 4 ms 5228 KB Output is correct
26 Correct 5 ms 5228 KB Output is correct
27 Correct 5 ms 5228 KB Output is correct
28 Correct 5 ms 5248 KB Output is correct
29 Correct 5 ms 5228 KB Output is correct
30 Correct 4 ms 5228 KB Output is correct
31 Correct 5 ms 5228 KB Output is correct
32 Correct 5 ms 5232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5100 KB Output is correct
2 Correct 3 ms 5100 KB Output is correct
3 Correct 3 ms 5100 KB Output is correct
4 Correct 3 ms 5100 KB Output is correct
5 Correct 4 ms 5100 KB Output is correct
6 Correct 3 ms 5100 KB Output is correct
7 Correct 4 ms 5100 KB Output is correct
8 Correct 3 ms 5100 KB Output is correct
9 Correct 4 ms 5100 KB Output is correct
10 Correct 3 ms 5100 KB Output is correct
11 Correct 4 ms 5100 KB Output is correct
12 Correct 4 ms 5100 KB Output is correct
13 Correct 4 ms 5100 KB Output is correct
14 Correct 4 ms 5100 KB Output is correct
15 Correct 4 ms 5228 KB Output is correct
16 Correct 4 ms 5100 KB Output is correct
17 Correct 5 ms 5248 KB Output is correct
18 Correct 4 ms 5228 KB Output is correct
19 Correct 4 ms 5228 KB Output is correct
20 Correct 4 ms 5228 KB Output is correct
21 Correct 5 ms 5228 KB Output is correct
22 Correct 5 ms 5228 KB Output is correct
23 Correct 5 ms 5228 KB Output is correct
24 Correct 4 ms 5228 KB Output is correct
25 Correct 4 ms 5228 KB Output is correct
26 Correct 5 ms 5228 KB Output is correct
27 Correct 5 ms 5228 KB Output is correct
28 Correct 5 ms 5248 KB Output is correct
29 Correct 5 ms 5228 KB Output is correct
30 Correct 4 ms 5228 KB Output is correct
31 Correct 5 ms 5228 KB Output is correct
32 Correct 5 ms 5232 KB Output is correct
33 Correct 124 ms 18156 KB Output is correct
34 Correct 135 ms 18540 KB Output is correct
35 Correct 131 ms 18412 KB Output is correct
36 Correct 127 ms 18796 KB Output is correct
37 Correct 132 ms 19180 KB Output is correct
38 Correct 131 ms 19052 KB Output is correct
39 Correct 127 ms 17964 KB Output is correct
40 Correct 131 ms 17900 KB Output is correct
41 Correct 127 ms 18156 KB Output is correct
42 Correct 128 ms 18176 KB Output is correct
43 Correct 129 ms 17900 KB Output is correct
44 Correct 129 ms 17684 KB Output is correct
45 Correct 130 ms 17644 KB Output is correct
46 Correct 128 ms 17644 KB Output is correct
47 Correct 103 ms 17604 KB Output is correct
48 Correct 102 ms 17644 KB Output is correct
49 Correct 130 ms 18284 KB Output is correct
50 Correct 138 ms 18284 KB Output is correct
51 Correct 132 ms 18284 KB Output is correct
52 Correct 134 ms 18284 KB Output is correct
53 Correct 132 ms 18284 KB Output is correct