답안 #918901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918901 2024-01-30T17:33:49 Z Haidara314 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
82 ms 10948 KB
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")*/
#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define ll long long
#define ll1 __int128
#define mid l+(r-l)/2
#define ya cout<<"YES"<<endl;
#define na cout<<"NO"<<endl;
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define pp pop_back();
#define C complex<ll>
#define R real()
#define I imag()
ll cross(C x,C y)
{
    return (conj(x)*y).I;
}
ll dot(C x,C y)
{
    return (conj(x)*y).R;
}
//abs(v) length of vector v
//arg(v) the angle of vector v in radians
//n polar(s,a) constructs a vector whose length is s and that points to an angle a
//rotate(vec.begin(), vec.begin() + k, vec.end());
//set<int> S(all(a));
/*if (S.count(key)) {
    // ...
}*/
/*if (binary_search(all(vec), key)) {
    // ...
}*/
//int pos = partition_point(all(vec), p) - vec.begin();
//Print a binary representation of a number cout << bitset<20>(n) << "\n";
int nxt()
{
    int x;
    cin >> x;
    return x;
}
ll1 lcm(ll1 x,ll1 y)
{
    return (x*y)/__gcd(x,y);
}
ll M=1000000007;
ll fp(ll x,ll y)
{
    if(y==0)
        return 1;
    ll m=fp(x,y/2);
    m*=m;
    m%=M;
    if(y%2==1)
        m*=x;
    m%=M;
    return m;
}
ll lg10(ll x)
{
    int o=0;
    while(x)
    {
        x/=10;
        o++;
    }
    return o;
}
int msb(int k)
{
    int g=__builtin_clz(k);
    return 31-g;
}
//vector<int>sv(100005);
/*ll m[1000005];
vector<int>divi[100005];
vector<int>p;
int y[100005];
void divg(int j,int i,int o,int c)
{
   if(i==p.size())
   {
       if(o!=1)
       divi[j][c].push_back(o);
       return;
   }
   divg(j,i+1,o*p[i],c+1);
   divg(j,i+1,o,c);
}*/
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*freopen("problemname.in", "r", stdin);
	freopen("problemname.out", "w", stdout);*/
    /*for(int i=2;i<=100005;i++)
    {
        if(!sv[i])
        {
            for(int j=i;j<=100005;j+=i)
                sv[j]=i;
        }
    }*/
    int n;
    cin>>n;
    int a[n+5];
    int b[n];
    for(int i=0;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    vector<pair<int,int>>p;
    for(int i=0;i<=n;i++)
    {
        p.push_back({a[i],i});
    }
    int c[n+5];
    sort(all(p));
    sort(b,b+n);
    int x[n];
    int o=0;
    for(int i=0;i<n;i++)
    {
        x[i]=max(o,max(0,p[i].F-b[i]));
        o=x[i];
    }
    c[p[n].S]=o;
    int h=0;
    for(int i=n-1;i>=0;i--)
    {
        h=max(h,max(0,p[i+1].F-b[i]));
        if(i!=0)
        c[p[i].S]=max(h,x[i-1]);
        else
        c[p[i].S]=h;
    }
    for(int i=0;i<=n;i++)
        cout<<c[i]<<" ";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 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 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 532 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 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 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 532 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 69 ms 10180 KB Output is correct
34 Correct 73 ms 10596 KB Output is correct
35 Correct 69 ms 10220 KB Output is correct
36 Correct 71 ms 10692 KB Output is correct
37 Correct 82 ms 10948 KB Output is correct
38 Correct 76 ms 10948 KB Output is correct
39 Correct 73 ms 9932 KB Output is correct
40 Correct 72 ms 9848 KB Output is correct
41 Correct 72 ms 9980 KB Output is correct
42 Correct 75 ms 10016 KB Output is correct
43 Correct 77 ms 9980 KB Output is correct
44 Correct 69 ms 9412 KB Output is correct
45 Correct 70 ms 9668 KB Output is correct
46 Correct 69 ms 9412 KB Output is correct
47 Correct 66 ms 9668 KB Output is correct
48 Correct 66 ms 9520 KB Output is correct
49 Correct 76 ms 10176 KB Output is correct
50 Correct 73 ms 10180 KB Output is correct
51 Correct 72 ms 10180 KB Output is correct
52 Correct 72 ms 10804 KB Output is correct
53 Correct 75 ms 10288 KB Output is correct