Submission #882941

# Submission time Handle Problem Language Result Execution time Memory
882941 2023-12-04T08:15:35 Z JakobZorz Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 348 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<int>a(n+1);
    vector<pair<int,int>>b(n);
    vector<int>ans(n+1);
    for(int&i:a)
        cin>>i;
    for(int i=0;i<n;i++){
        cin>>b[i].first;
        b[i].second=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]-b[i].first);
    
    ans[b[0].second]=max(0,*--s.end());
    for(int i=0;i<n;i++){
        s.erase(s.find(a[i+1]-b[i].first));
        s.insert(a[i]-b[i].first);
        ans[b[i].second+1]=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

5
4 7 9 10 11 12
3 5 7 9 11
 
 */
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -