답안 #882943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882943 2023-12-04T08:21:33 Z JakobZorz Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
241 ms 18676 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second

void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>>a(n+1);
    vector<int>b(n);
    vector<int>ans(n+1);
    for(int i=0;i<=n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    for(int&i:b)
        cin>>i;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    multiset<int>s;
    for(int i=0;i<n;i++)
        s.insert(a[i+1].first-b[i]);
    
    ans[a[0].second]=max(0,*--s.end());
    for(int i=0;i<n;i++){
        s.erase(s.find(a[i+1].first-b[i]));
        s.insert(a[i].first-b[i]);
        ans[a[i+1].second]=max(0,*--s.end());
    }
    
    for(int i:ans)
        cout<<i<<" ";
    cout<<"\n";
}

int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}

/*
 
3
3 4 7 6
2 6 4

3
6 7 3 4
2 6 4
 
5
4 7 9 10 11 12
3 5 7 9 11
 
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 520 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 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 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 520 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 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 600 KB Output is correct
33 Correct 153 ms 17496 KB Output is correct
34 Correct 149 ms 18132 KB Output is correct
35 Correct 149 ms 17668 KB Output is correct
36 Correct 148 ms 18072 KB Output is correct
37 Correct 156 ms 18676 KB Output is correct
38 Correct 149 ms 18604 KB Output is correct
39 Correct 241 ms 17492 KB Output is correct
40 Correct 184 ms 17464 KB Output is correct
41 Correct 194 ms 17492 KB Output is correct
42 Correct 179 ms 17492 KB Output is correct
43 Correct 196 ms 17492 KB Output is correct
44 Correct 139 ms 16864 KB Output is correct
45 Correct 135 ms 17104 KB Output is correct
46 Correct 140 ms 16724 KB Output is correct
47 Correct 136 ms 17232 KB Output is correct
48 Correct 130 ms 17232 KB Output is correct
49 Correct 193 ms 17904 KB Output is correct
50 Correct 204 ms 17884 KB Output is correct
51 Correct 187 ms 17944 KB Output is correct
52 Correct 198 ms 17868 KB Output is correct
53 Correct 191 ms 17952 KB Output is correct