Submission #718031

# Submission time Handle Problem Language Result Execution time Memory
718031 2023-04-03T08:00:40 Z niter Just Long Neckties (JOI20_ho_t1) C++14
9 / 100
4 ms 472 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define mp make_pair
using namespace std;

void debug(){
    cout << "\n";
}
template<class T, class ...U>
void debug(T a, U ...b){
    cout << a << " "; debug(b...);
}

// 2020 A

const int maxN = 2000; //200005;

int main(){
    int n;
    cin >> n;
    pii a[maxN];
    int b[maxN];
    loop(i,0,n+1){
        cin >> a[i].ff;
        a[i].ss = i + 1;
    }
    loop(i,0,n){
        cin >> b[i];
    }
    sort(a, a + n + 1);
    sort(b, b + n);
    vector<pii> dos;
    multiset<pii> S;
    int ans[maxN] = {0};
    loop(i,0,n){
        S.ins( mp( max(a[i].ff - b[i], 0), a[i].ss) );
        dos.pb(mp( max(a[i].ff - b[i], 0), a[i].ss ));
    }
//    for(auto &i:S){
//        debug(i.ff, i.ss);
//    }
    ans[a[n].ss] = (prev(S.end()))->ff;
    for(int i = n-1; i >= 0; i--){
        S.erase(S.find(dos[i]));
        S.insert( mp(max(a[i+1].ff - b[i], 0), a[i+1].ss) );
        ans[a[i].ss] = (prev(S.end()))->ff;
        //debug("ans[", a[i].ss, "] =", ans[a[i].ss]);
    }
    loop(i,1,n+2){
        cout << ans[i] << " ";
    } cout << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 352 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 4 ms 464 KB Output is correct
26 Correct 4 ms 468 KB Output is correct
27 Correct 4 ms 468 KB Output is correct
28 Correct 4 ms 472 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 3 ms 352 KB Output is correct
31 Correct 3 ms 468 KB Output is correct
32 Correct 4 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 352 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 4 ms 464 KB Output is correct
26 Correct 4 ms 468 KB Output is correct
27 Correct 4 ms 468 KB Output is correct
28 Correct 4 ms 472 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 3 ms 352 KB Output is correct
31 Correct 3 ms 468 KB Output is correct
32 Correct 4 ms 472 KB Output is correct
33 Runtime error 2 ms 468 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -