Submission #881723

# Submission time Handle Problem Language Result Execution time Memory
881723 2023-12-01T19:06:59 Z alexdd Schools (IZhO13_school) C++17
0 / 100
1225 ms 8628 KB
#include<bits/stdc++.h>
using namespace std;
const int NRIT = 3e7;
int n,m,s;
pair<int,pair<int,int>> v[300005];
int unde[300005];
mt19937 rnd(293123);
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m>>s;
    int a,b;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b;
        v[i] = {a-b,{a,b}};
    }
    sort(v+1,v+1+n);
    for(int i=1;i<=s;i++)
    {
        unde[i]=2;
    }
    for(int i=1;i<=m;i++)
    {
        unde[i]=1;
    }
    for(int pas=0;pas<NRIT;pas++)
    {
        int x = rnd()%n;
        int y = rnd()%n;
        if(unde[x]==unde[y])
            continue;
        if(unde[y]==0)
            swap(x,y);
        if(unde[x]==0)
        {
            if(unde[y]==1)
            {
                if(v[x].second.first - v[y].second.first > 0)
                    swap(unde[x],unde[y]);
            }
            else
            {
                if(v[x].second.second - v[y].second.second > 0)
                    swap(unde[x],unde[y]);
            }
        }
        else
        {
            if(unde[x]==2)
                swap(x,y);
            if(v[x].second.second - v[x].second.first + v[y].second.first - v[y].second.second > 0)
            {
                swap(unde[x],unde[y]);
            }
        }
    }
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        if(unde[i]==1)
            sum += v[i].second.first;
        else if(unde[i]==2)
            sum += v[i].second.second;
    }
    cout<<sum;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1053 ms 2500 KB Output isn't correct
2 Incorrect 958 ms 2496 KB Output isn't correct
3 Incorrect 1026 ms 2492 KB Output isn't correct
4 Incorrect 1112 ms 2492 KB Output isn't correct
5 Incorrect 1115 ms 2496 KB Output isn't correct
6 Incorrect 1086 ms 2496 KB Output isn't correct
7 Incorrect 992 ms 2564 KB Output isn't correct
8 Incorrect 738 ms 2564 KB Output isn't correct
9 Incorrect 865 ms 2572 KB Output isn't correct
10 Incorrect 889 ms 2568 KB Output isn't correct
11 Incorrect 1050 ms 2576 KB Output isn't correct
12 Incorrect 952 ms 2588 KB Output isn't correct
13 Incorrect 832 ms 2908 KB Output isn't correct
14 Incorrect 1089 ms 3532 KB Output isn't correct
15 Incorrect 761 ms 6320 KB Output isn't correct
16 Incorrect 1029 ms 6856 KB Output isn't correct
17 Incorrect 1225 ms 7280 KB Output isn't correct
18 Incorrect 1139 ms 7628 KB Output isn't correct
19 Incorrect 1181 ms 7764 KB Output isn't correct
20 Incorrect 1200 ms 8628 KB Output isn't correct