답안 #206954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206954 2020-03-06T01:42:09 Z wiwiho Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
305 ms 14996 KB
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a) / (b) + !!((a) % (b)))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
using namespace __gnu_pbds;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}


int main(){
    StarBurstStream

    int n;
    cin >> n;

    vector<pii> a(n + 1);
    for(int i = 0; i < n + 1; i++){
        cin >> a[i].F;
        a[i].S = i;
    }

    lsort(a);

    vector<int> ans(n + 1);

    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> b[i];
    lsort(b);

    multiset<int> s;
    for(int i = 0; i < n; i++) s.insert(max(a[i].F - b[i], 0));
    ans[a.back().S] = *s.rbegin();

    for(int i = n - 1; i >= 0;i --){
        s.erase(s.find(max(a[i].F - b[i], 0)));
        s.insert(max(a[i + 1].F - b[i], 0));
        ans[a[i].S] = *s.rbegin();
    }

    printv(ans, cout);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 428 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 428 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 508 KB Output is correct
33 Correct 220 ms 13816 KB Output is correct
34 Correct 253 ms 14424 KB Output is correct
35 Correct 214 ms 13820 KB Output is correct
36 Correct 234 ms 14456 KB Output is correct
37 Correct 250 ms 14996 KB Output is correct
38 Correct 241 ms 14712 KB Output is correct
39 Correct 294 ms 13664 KB Output is correct
40 Correct 288 ms 13688 KB Output is correct
41 Correct 301 ms 13816 KB Output is correct
42 Correct 289 ms 13688 KB Output is correct
43 Correct 287 ms 13948 KB Output is correct
44 Correct 203 ms 13176 KB Output is correct
45 Correct 202 ms 13304 KB Output is correct
46 Correct 200 ms 13176 KB Output is correct
47 Correct 185 ms 13432 KB Output is correct
48 Correct 217 ms 13432 KB Output is correct
49 Correct 305 ms 14072 KB Output is correct
50 Correct 304 ms 14200 KB Output is correct
51 Correct 302 ms 14072 KB Output is correct
52 Correct 291 ms 14072 KB Output is correct
53 Correct 285 ms 14200 KB Output is correct