Submission #1088769

# Submission time Handle Problem Language Result Execution time Memory
1088769 2024-09-15T02:57:19 Z ntdaccode Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
74 ms 15648 KB
//de y tung cac mang 1
#include<bits/stdc++.h>
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define pb push_back
#define ii pair<int,int>
#define fi first
#define se second
using namespace std;
const int M=2e5+10;
int n,b[M],ret[M],f[M],g[M];
ii a[M];
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if(fopen("1.inp","r"))
  {
    freopen("1.inp","r",stdin);
    freopen("1.out","w",stdout);
  }
  cin >> n;
  fori(i,1,n+1)
  {
    cin >> a[i].fi;
    a[i].se=i;
  }
  fori(i,1,n) cin >> b[i];
  sort(a+1,a+n+2);
  sort(b+1,b+n+1);
  //fori(i,1,n+1) cout << a[i] << " ";
  fori(i,1,n) f[i]=max(f[i-1],max(0ll,a[i].fi-b[i]));
  for(int i=n+1;i!=1;i--) g[i]=max(g[i+1],max(0ll,a[i].fi-b[i-1]));
  fori(i,1,n+1) ret[a[i].se]=max(f[i-1],g[i+1]);
  fori(i,1,n+1) cout << ret[i] << " ";
}

Compilation message

ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("1.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("1.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 532 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 532 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 63 ms 14416 KB Output is correct
34 Correct 74 ms 15188 KB Output is correct
35 Correct 66 ms 14672 KB Output is correct
36 Correct 64 ms 15160 KB Output is correct
37 Correct 67 ms 15648 KB Output is correct
38 Correct 68 ms 15304 KB Output is correct
39 Correct 63 ms 14412 KB Output is correct
40 Correct 66 ms 14416 KB Output is correct
41 Correct 63 ms 14456 KB Output is correct
42 Correct 63 ms 14420 KB Output is correct
43 Correct 64 ms 14416 KB Output is correct
44 Correct 64 ms 13904 KB Output is correct
45 Correct 64 ms 13844 KB Output is correct
46 Correct 61 ms 13904 KB Output is correct
47 Correct 58 ms 14164 KB Output is correct
48 Correct 68 ms 14164 KB Output is correct
49 Correct 66 ms 14636 KB Output is correct
50 Correct 65 ms 14672 KB Output is correct
51 Correct 65 ms 14632 KB Output is correct
52 Correct 71 ms 14676 KB Output is correct
53 Correct 64 ms 14672 KB Output is correct