Submission #724258

# Submission time Handle Problem Language Result Execution time Memory
724258 2023-04-15T02:07:58 Z Cookie Just Long Neckties (JOI20_ho_t1) C++14
9 / 100
247 ms 21696 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, 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);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 484 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 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 2 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 2 ms 476 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 484 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 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 2 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 2 ms 476 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 174 ms 20400 KB Output is correct
34 Correct 197 ms 21252 KB Output is correct
35 Correct 175 ms 20720 KB Output is correct
36 Correct 191 ms 21128 KB Output is correct
37 Correct 186 ms 21696 KB Output is correct
38 Correct 179 ms 21608 KB Output is correct
39 Correct 247 ms 20468 KB Output is correct
40 Correct 233 ms 20384 KB Output is correct
41 Correct 238 ms 20712 KB Output is correct
42 Correct 238 ms 20548 KB Output is correct
43 Correct 238 ms 20392 KB Output is correct
44 Correct 167 ms 19784 KB Output is correct
45 Correct 162 ms 19964 KB Output is correct
46 Correct 164 ms 19708 KB Output is correct
47 Incorrect 140 ms 19896 KB Output isn't correct
48 Halted 0 ms 0 KB -