답안 #781661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781661 2023-07-13T09:22:38 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define OYY 1000000005
#define mod 998244353
#define mid (start+end)/2
vector <int> v,v2;
int re[1000005],tree[8000005];

void build(int node,int start,int end){
    if(start==end){
        tree[node]=re[start];
        return ;
    }
    build(node*2,start,mid),build(node*2+1,mid+1,end);
    tree[node]=max(tree[node*2],tree[node*2+1]);
}

int query(int node,int start,int end,int l,int r){
    if(start>end || start>r || end<l)return 0;
    if(start>=l&& end<=r)return tree[node];
    return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r));
}

void update(int node,int start,int end,int l,int r,int val){
    if(start>end || start>r || end<l)return ;
    if(start>=l&& end<=r){
        tree[node]=val;
        return ;
    }
    update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
    tree[node]=max(tree[node*2],tree[node*2+1]);
}

int32_t main(){
    faster
    int n;cin>>n;
    int dizi[n+1],di[n];
    for(int i=0;i<=n;i++)cin>>dizi[i];
    for(int i=0;i<n;i++)cin>>di[i];
    sort(dizi,dizi+n);
    sort(di,di+n);
    int maxi=0;
    for(int i=1;i<=n;i++){
       // cout<<dizi[i]<<" "<<di[]
        v.push_back(max(dizi[i]-di[i-1],(int)0));
        maxi=max(maxi,v[i-1]);
    }
    for(int i=0;i<n;i++){
        v2.push_back(max(dizi[i]-di[i],(int)0));
    }
    for(int i=0;i<v.size();i++){
        re[i]=v[i];
    }
    build(1,1,n);
    cout<<maxi<<" ";
    for(int i=0;i<v.size();i++){
        update(1,1,n,i,i,v2[i]);
        cout<<query(1,1,n,1,n)<<" ";
    }
    cout<<endl;
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:53:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
ho_t1.cpp:58:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -