| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 90729 | Aydarov03 | Schools (IZhO13_school) | C++14 | 2 ms | 828 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define fr first
#define sc second
using namespace std;
const int N = 2e5+10;
const int inf = 1e9+7;
bool cmp( pair<int,int> a, pair<int,int> b)
{
    a.sc > b.sc;
}
pair <int,int> a[300005];
vector < pair<int,int> > v1 , v2;
main()
{
    freopen("school.in" , "r" , stdin );
    freopen("school.out" , "w" , stdout );
    int n , m , s , ans = 0;
    cin >> n >> m >> s;
    int cnt1 = m , cnt2 = s;
    for(int i = 1; i <= n; i++)
        cin >> a[i].fr >> a[i].sc;
//    system("cls");
    sort( a + 1 , a + n + 1 );
    for(int i = 1; i <= n; i++)v1.push_back( a[i] );
    sort( a + 1 , a + n + 1 , &cmp);
    for(int i = 1; i <= n; i++)v2.push_back( a[i] );
    system("cls");
    for(int i = 0; i < n; i += 2)
    {
        if( cnt1 == 0 )
        {
            while( cnt2-- )ans += v2[i].sc;
            break;
        }
        else if( cnt2 == 0 )
        {
            while( cnt1-- )ans += v1[i].fr;
            break;
        }
        else
        {
            ans += max( v1[i].fr + v2[i+1].sc , v1[i+1].fr + v2[i].sc);
            cnt1-- , cnt2--;
        }
    }
    cout << ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
