Submission #1063219

# Submission time Handle Problem Language Result Execution time Memory
1063219 2024-08-17T15:26:53 Z vjudge1 Fortune Telling 2 (JOI14_fortune_telling2) C++17
0 / 100
2 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
const int N=200000;
ll n,k;
vector<pair<ll,ll>>cards;


int binary(ll low, ll mid, ll hi, ll val){

    while(low!=mid){
        //cout<<low<<" "<<mid<<" "<<hi<<" LO MID HI1"<<endl;
        if(cards[mid].ff<=val){
            low=mid;
            mid=(low+hi+1)/2;
        }else{
            hi=mid-1;
            mid=(low+hi)/2;
        }
        //cout<<low<<" "<<mid<<" "<<hi<<" LO MID HI2"<<endl;
    }
    //cout<<"a"<<endl;
    return mid;
}

int main(){
    cin >> n >> k;

    for(ll i=0;i<n;i++){
        ll a,b; cin>>a>>b;
        cards.pb({a,b});
    }



    for(ll i=0;i<k;i++){
        sort(cards.begin(),cards.end());

        ll t; cin >> t;
        ll indi=binary(0,((n-1)/2),n-1,t);
        for(ll j=0;j<=indi;j++){


            swap(cards[j].ff,cards[j].ss);
        }


    }
    ll sum=0;
    for(ll x=0;x<n;x++){
        sum+=cards[x].ff;
    }
    cout<<sum<<endl;


}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -