Submission #89063

# Submission time Handle Problem Language Result Execution time Memory
89063 2018-12-10T09:22:37 Z luka1234 Schools (IZhO13_school) C++14
10 / 100
282 ms 10204 KB
#include <bits/stdc++.h>

using namespace std;
int q1[10001],q2[10001];
int main()
{
    int n,x,y,mx1=0,mx2=0,s=1,hhh=0;
    cin>>n>>x>>y;
    pair<int,int> a[n],b[n];

    for(int k=0;k<n;k++){
        cin>>a[k].first;
        cin>>a[k].second;
        b[k].first=a[k].second;
        b[k].second=a[k].first;
    }

    sort(a,a+n);
    sort(b,b+n);

    for(int k=0;k<x;k++){
        mx1=mx1+a[n-s].first;
        q1[a[n-s].first]=1;
        s++;
    }
    for(int k=n-1;k>=0;k--){
        if(hhh==y)break;
        if(q1[b[k].second]==0){
            mx1=mx1+b[k].first;
            hhh++;
        }
    }



   s=1;
   hhh=0;

   for(int k=0;k<y;k++){
        mx2=mx2+b[n-s].first;
        q2[b[n-s].first]=1;
        s++;
    }
    for(int k=n-1;k>=0;k--){
        if(hhh==x)break;
        if(q2[a[k].second]==0){
            mx2=mx2+a[k].first;
            hhh++;
        }
    }
    cout<<max(mx1,mx2);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Incorrect 2 ms 524 KB Output isn't correct
5 Runtime error 1 ms 544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 6 ms 836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 6 ms 948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 6 ms 948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 7 ms 948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 7 ms 1012 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 33 ms 1972 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 72 ms 3260 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 152 ms 5864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 171 ms 6476 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 214 ms 7756 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 229 ms 8392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 251 ms 9052 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 282 ms 10204 KB Execution killed with signal 11 (could be triggered by violating memory limits)