답안 #724259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724259 2023-04-15T02:08:43 Z Cookie Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
272 ms 21132 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("WINTER.inp");
ofstream fout("WINTER.out");
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const ll mod = 1e9 + 7;
const int mxn = 2e5 + 5, mxm = 1e5;
int n;
ll ans[mxn + 1];
signed main(){
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    vt<pair<ll, int>>b;
    vt<ll>a;
    forr(i, 1, n + 2){
        int x; cin >> x;
        b.pb(make_pair(x, i));
    }
    sort(b.begin(), b.end());
    forr(i, 1, n + 1){
        int x; cin >> x;
        a.pb(x);
    }
    sort(a.begin(), a.end());
    multiset<ll>ms;
    for(int i = 0; i < n; i++){
        ms.insert(max(b[i + 1].first - a[i], (ll)0));
    }
    ans[b[0].se] = *ms.rbegin();
    
    for(int i = 1; i <= n; i++){
        // if choosen if i
        ms.erase(ms.find(max(b[i].first - a[i - 1], (ll)0)));
        ms.insert(max(b[i - 1].first - a[i - 1], (ll)0));
        
        ans[b[i].second] = *ms.rbegin();
    }
    forr(i, 1, n + 2)cout << ans[i] << ' ';
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 181 ms 16708 KB Output is correct
34 Correct 190 ms 17408 KB Output is correct
35 Correct 170 ms 16908 KB Output is correct
36 Correct 174 ms 17408 KB Output is correct
37 Correct 188 ms 17892 KB Output is correct
38 Correct 176 ms 17780 KB Output is correct
39 Correct 234 ms 16684 KB Output is correct
40 Correct 248 ms 16524 KB Output is correct
41 Correct 229 ms 16716 KB Output is correct
42 Correct 256 ms 16704 KB Output is correct
43 Correct 247 ms 16692 KB Output is correct
44 Correct 151 ms 16100 KB Output is correct
45 Correct 158 ms 16232 KB Output is correct
46 Correct 161 ms 16128 KB Output is correct
47 Correct 155 ms 16452 KB Output is correct
48 Correct 169 ms 20452 KB Output is correct
49 Correct 272 ms 21020 KB Output is correct
50 Correct 254 ms 21124 KB Output is correct
51 Correct 258 ms 21076 KB Output is correct
52 Correct 250 ms 21104 KB Output is correct
53 Correct 244 ms 21132 KB Output is correct