답안 #285558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
285558 2020-08-29T08:52:54 Z leductoan Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
495 ms 18720 KB
#include<bits/stdc++.h>
using namespace std;
#define task "JOI20_ho_t1"
#define lb lower_bound
#define ub upper_bound
#define ALL(v) (v).begin(),(v).end()
#define zs(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const ll mod=1000000007; /// 998244353
const int base=311;
const int N=2e5+5;

int n,b[N],ans[N];
pii a[N];
void biot()
{
    cin>>n;
    for(int i=1;i<=n+1;++i) cin>>a[i].fi, a[i].se=i;
    sort(a+1,a+n+2);
    for(int i=1;i<=n;++i) cin>>b[i];
    sort(b+1,b+n+1);
    multiset<int,greater<int>> s;
    for(int i=1;i<=n;++i) s.insert(max(0,a[i+1].fi-b[i]));
    ans[a[1].se]=*s.begin();
    for(int i=2;i<=n+1;++i)
    {
        s.erase(s.find(max(0,a[i].fi-b[i-1])));
        s.insert(max(0,a[i-1].fi-b[i-1]));
        ans[a[i].se]=*s.begin();
    }
    for(int i=1;i<=n+1;++i) cout<<ans[i]<<' ';
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    biot();
}











Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   46 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   47 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 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 1 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 0 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 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 2 ms 576 KB Output is correct
27 Correct 3 ms 640 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 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 0 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 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 2 ms 576 KB Output is correct
27 Correct 3 ms 640 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 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 249 ms 17560 KB Output is correct
34 Correct 274 ms 18168 KB Output is correct
35 Correct 232 ms 17656 KB Output is correct
36 Correct 258 ms 18116 KB Output is correct
37 Correct 269 ms 18720 KB Output is correct
38 Correct 251 ms 18552 KB Output is correct
39 Correct 350 ms 17400 KB Output is correct
40 Correct 371 ms 17348 KB Output is correct
41 Correct 379 ms 17528 KB Output is correct
42 Correct 399 ms 17576 KB Output is correct
43 Correct 375 ms 17528 KB Output is correct
44 Correct 246 ms 16888 KB Output is correct
45 Correct 195 ms 17016 KB Output is correct
46 Correct 206 ms 16892 KB Output is correct
47 Correct 189 ms 17368 KB Output is correct
48 Correct 214 ms 17424 KB Output is correct
49 Correct 495 ms 17912 KB Output is correct
50 Correct 355 ms 18040 KB Output is correct
51 Correct 306 ms 17912 KB Output is correct
52 Correct 342 ms 18040 KB Output is correct
53 Correct 351 ms 17912 KB Output is correct