답안 #320610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320610 2020-11-09T08:50:39 Z teehandsome Just Long Neckties (JOI20_ho_t1) C++11
100 / 100
137 ms 10852 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {for(auto e:x) cerr<<e<<",";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

int n;
vector<pii> a;
vector<int> b;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n; a.resize(n+1); b.resize(n);
    for(int i=0;i<=n;i++) {
        cin>>a[i].first; a[i].second=i;
    }
    vector<int> idx(n+1);
    sort(all(a));
    for(int i=0;i<=n;i++) idx[a[i].second]=i;
    for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
    vector<int> dif(n),dif1(n);
    for(int i=0;i<n;i++) {
        dif[i]=max(a[i].first-b[i],0);
        dif1[i]=max(a[i+1].first-b[i],0);
    }
    for(int i=1;i<n;i++) {
        dif[i]=max(dif[i],dif[i-1]);
    }
    for(int i=n-2;i>=0;i--) {
        dif1[i]=max(dif1[i],dif1[i+1]);
    }
    for(int i=0;i<=n;i++) {
        int j=idx[i];
        if(j==n) cout<<dif[n-1]<<' ';
        else {
            int res=dif1[j];
            if(j) res=max(res,dif[j-1]);
            cout<<res<<' ';
        }
    }
    cout<<endl;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:42:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |     for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
      |     ^~~
ho_t1.cpp:42:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |     for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
      |                                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 416 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 416 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 360 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 416 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 360 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 108 ms 6368 KB Output is correct
34 Correct 137 ms 10468 KB Output is correct
35 Correct 112 ms 10084 KB Output is correct
36 Correct 108 ms 10596 KB Output is correct
37 Correct 113 ms 10852 KB Output is correct
38 Correct 112 ms 10724 KB Output is correct
39 Correct 110 ms 9828 KB Output is correct
40 Correct 110 ms 9860 KB Output is correct
41 Correct 111 ms 9956 KB Output is correct
42 Correct 114 ms 9828 KB Output is correct
43 Correct 106 ms 9956 KB Output is correct
44 Correct 109 ms 9444 KB Output is correct
45 Correct 107 ms 9444 KB Output is correct
46 Correct 107 ms 9448 KB Output is correct
47 Correct 99 ms 9572 KB Output is correct
48 Correct 100 ms 9572 KB Output is correct
49 Correct 127 ms 10084 KB Output is correct
50 Correct 110 ms 10084 KB Output is correct
51 Correct 124 ms 10084 KB Output is correct
52 Correct 114 ms 10084 KB Output is correct
53 Correct 111 ms 10084 KB Output is correct