답안 #315336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315336 2020-10-22T14:17:34 Z Dymo Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
109 ms 15608 KB
#include<bits/stdc++.h>

using namespace std;


#define pb	push_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=5e5+50;
const ll mod =1e9+7;
const ll base=113;
pll a[maxn];
ll l[maxn];
ll r[maxn];
ll b[maxn];
ll ans[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("GIDDY.inp", "r"))
    {
        freopen("GIDDY.inp", "r", stdin);
        freopen("GIDDY.out", "w", stdout) ;
    }
    ll n;
     cin>>n ;
     for (int i=1;i<=n+1;i++)
     {
         cin>>a[i].ff;
         a[i].ss=i;
     }
     sort(a+1,a+n+2);
    /* for (int i=1;i<=n+1;i++)
     {
         cout <<a[i].ff<<" "<<a[i].ss<<endl;
     }*/
     for (int i=1;i<=n;i++)
     {
        cin>>b[i];
     }
     sort(b+1,b+n+1);
     for (int i=1;i<=n;i++)
     {
       l[i]=max(l[i-1],max(0ll,a[i].ff-b[i]));

     }
     for (int i=n;i>=1;i--)
     {
         r[i]=max(r[i+1],max(0ll,a[i+1].ff-b[i]));
     }
     for (int i=1;i<=n+1;i++)
     {
         ans[a[i].ss]=max(l[i-1],r[i]);
        /*
           //  cout <<l[i-1]<<" "<<r[i+1]<<" "<<i<<endl;
         }*/
     }
     for (int i=1;i<=n+1;i++)
     {
         cout <<ans[i]<<" ";
     }



}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   28 |         freopen("GIDDY.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         freopen("GIDDY.out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 104 ms 14584 KB Output is correct
34 Correct 105 ms 15096 KB Output is correct
35 Correct 104 ms 14584 KB Output is correct
36 Correct 105 ms 15096 KB Output is correct
37 Correct 109 ms 15608 KB Output is correct
38 Correct 108 ms 15396 KB Output is correct
39 Correct 102 ms 14456 KB Output is correct
40 Correct 106 ms 14328 KB Output is correct
41 Correct 105 ms 14712 KB Output is correct
42 Correct 103 ms 14456 KB Output is correct
43 Correct 101 ms 14328 KB Output is correct
44 Correct 109 ms 13944 KB Output is correct
45 Correct 100 ms 14072 KB Output is correct
46 Correct 100 ms 14072 KB Output is correct
47 Correct 97 ms 14308 KB Output is correct
48 Correct 101 ms 14328 KB Output is correct
49 Correct 106 ms 14840 KB Output is correct
50 Correct 105 ms 14840 KB Output is correct
51 Correct 108 ms 14840 KB Output is correct
52 Correct 105 ms 14788 KB Output is correct
53 Correct 109 ms 14840 KB Output is correct