Submission #895569

# Submission time Handle Problem Language Result Execution time Memory
895569 2023-12-30T09:22:39 Z presko Schools (IZhO13_school) C++14
15 / 100
96 ms 10164 KB
#include<iostream>
#include<bits/stdc++.h>
#define MAXN 300010
using namespace std;
pair<int,int> city[MAXN];
vector<pair<int,int>> order;
vector<pair<int,int>> var;
bool used1[MAXN];
bool used2[MAXN];
int main()
{
    int n,m,s;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>s;
    for(int i=1;i<=n;i++)
    {
        cin>>city[i].first>>city[i].second;
        order.push_back({city[i].first,i});
        var.push_back({city[i].second,i});
    }
    sort(order.begin(),order.end(),greater<pair<int,int>>());
    sort(var.begin(),var.end(),greater<pair<int,int>>());
    long long ans1=0,ans2=0;
    for(int i=0;i<m;i++)
    {
        int mus=order[i].first;
        int ind=order[i].second;
        ans1+=mus;
        used1[ind]=1;
    }
    int cntr=s;
    for(int i=0;i<var.size();i++)
    {
        int sp=var[i].first;
        int ind=var[i].second;
        if(used1[ind]==0)
        {
            ans1+=sp;
            cntr--;
        }
        if(cntr==0)break;
    }
    for(int i=0;i<s;i++)
    {
        int sp=var[i].first;
        int ind=var[i].second;
        ans2+=sp;
        used2[ind]=1;
    }
    cntr=m;
    for(int i=0;i<order.size();i++)
    {
        int mus=order[i].first;
        int ind=order[i].second;
        if(used2[ind]==0)
        {
            ans2+=mus;
            cntr--;
        }
        if(cntr==0)break;
    }
    if(ans1<=ans2)cout<<ans2<<"\n";
    else cout<<ans1<<"\n";
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<var.size();i++)
      |                 ~^~~~~~~~~~~
school.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<order.size();i++)
      |                 ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Incorrect 0 ms 2396 KB Output isn't correct
5 Incorrect 0 ms 2396 KB Output isn't correct
6 Incorrect 0 ms 2396 KB Output isn't correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Incorrect 2 ms 2652 KB Output isn't correct
9 Incorrect 2 ms 2652 KB Output isn't correct
10 Incorrect 3 ms 2852 KB Output isn't correct
11 Incorrect 2 ms 2652 KB Output isn't correct
12 Incorrect 2 ms 2652 KB Output isn't correct
13 Incorrect 10 ms 3288 KB Output isn't correct
14 Incorrect 26 ms 4296 KB Output isn't correct
15 Correct 52 ms 5828 KB Output is correct
16 Incorrect 54 ms 5828 KB Output isn't correct
17 Incorrect 68 ms 6212 KB Output isn't correct
18 Incorrect 77 ms 6832 KB Output isn't correct
19 Incorrect 79 ms 7344 KB Output isn't correct
20 Incorrect 96 ms 10164 KB Output isn't correct