Submission #208343

# Submission time Handle Problem Language Result Execution time Memory
208343 2020-03-10T19:44:16 Z mohamedsobhi777 Schools (IZhO13_school) C++14
5 / 100
333 ms 11208 KB
#include<bits/stdc++.h> 
 
using namespace std ;

const int N = 1e6 + 7 , mod = 998244353; 

long long n   , A , B ; 
long long a[N] , b[N] ; 
long long ans ; 
int vis[N]; 

int main() 
{
    //freopen("in.in" , "r" , stdin) ; 
    cin>>n>>A>>B ; 
    vector<pair<int , int > > v , v2 ; 
    for(int i = 0 ; i < n ; i++){
        cin>>a[i] >> b[i] ;
        v.push_back({-a[i] , i}) ; 
        v2.push_back({-b[i] , i});
    }
    sort(v.begin() , v.end()) ;
    sort(v2.begin() , v2.end()) ; 
    int j = A;
    for(int i=  0 ; i < A ; i++){
        ans-=v[i].first ; 
        vis[v[i].second] = 1 ; 
    }

    for(int i = 0 ; i < B ; i++){
        int val = -v2[i].first ; 
        int idx = v2[i].second ;
        if(vis[idx]++) {
            while(vis[v[j].second]){
                j++;
            }
            if( val - v[j] .first > - v[i].first  )
            {
                vis[ v[j].second ] = 1 ; 
                ans+=val -v[j].first + v[i] .first ; 
            }
            else {
                B++;
            }
        }
        else {
            ans+=val; 
        }
    }
    cout<<ans; 
    return 0 ;  
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Incorrect 5 ms 376 KB Output isn't correct
7 Incorrect 9 ms 632 KB Output isn't correct
8 Incorrect 9 ms 664 KB Output isn't correct
9 Incorrect 9 ms 632 KB Output isn't correct
10 Incorrect 12 ms 760 KB Output isn't correct
11 Incorrect 10 ms 632 KB Output isn't correct
12 Incorrect 10 ms 632 KB Output isn't correct
13 Incorrect 41 ms 1908 KB Output isn't correct
14 Incorrect 84 ms 3424 KB Output isn't correct
15 Incorrect 168 ms 6232 KB Output isn't correct
16 Incorrect 200 ms 6992 KB Output isn't correct
17 Incorrect 244 ms 8280 KB Output isn't correct
18 Incorrect 266 ms 9052 KB Output isn't correct
19 Incorrect 284 ms 9812 KB Output isn't correct
20 Incorrect 333 ms 11208 KB Output isn't correct