Codeforces Round 965 (Div. 2) || Editorial for Problem A,B,C

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024

ความคิดเห็น • 1

  • @nicspyy
    @nicspyy  2 หลายเดือนก่อน

    B solution:
    void solve(){

    int n;
    cin>>n;
    vi a(n);
    forn(i,0,n) cin>>a[i];

    for(int i=0; i n >> k;
    int a[n], b[n];
    bool haveOne = false;
    pair t[n];
    for(int i = 0; i < n; i++){
    cin >> t[i].ff;
    }
    for(int i = 0; i < n; i++){
    cin >> t[i].ss;
    }
    sort(t, t + n);
    for(int i = 0; i < n; i++){
    a[i] = t[i].ff;
    b[i] = t[i].ss;
    haveOne |= b[i];
    }
    int ans1 = 0;
    if(haveOne){
    for(int i = n - 1; i>=0; i--){
    if(b[i]){
    vector t;
    t.pb(a[i] + k);
    for(int j = 0; j < n; j++){
    if(i == j){
    continue;
    }
    t.pb(a[j]);
    }
    sort(all(t));
    ans1 = vMed(t, n - 1) + t[n - 1];
    break;
    }
    }
    }
    else{
    cout