Submission #89030

#TimeUsernameProblemLanguageResultExecution timeMemory
89030tarash117학교 설립 (IZhO13_school)C++14
20 / 100
120 ms7620 KiB
#include<bits/stdc++.h>
using namespace std;
struct abc{
 int x;
 int i;
};
bool ioni(abc a,abc b){
  return a.x>b.x;
}
int used1[300001],used2[300001];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
int n,m,s;
cin>>n>>m>>s;
abc a[n+1],b[n+1];
for(int i=1;i<=n;i++){
    cin>>a[i].x>>b[i].x;
    a[i].i=i;
    b[i].i=i;
}
sort(a+1,a+1+n,ioni);
sort(b+1,b+1+n,ioni);

int mx1=0;
for(int i=1;i<=m;i++){
    mx1+=a[i].x;
    used1[a[i].i]++;
}
int j=1;

for(int i=1;i<=n;i++){
   if(j>s)
    break;

    if(used1[b[i].i]==0){
        mx1+=b[i].x;
        j++;
    }

}

int mx2=0;
for(int i=1;i<=s;i++){
    mx2+=b[i].x;
    used2[b[i].i]=1;
}
 j=1;

for(int i=1;i<=n;i++){
   if(j>m)
    break;

    if(used2[a[i].i]==0){
        mx2+=a[i].x;
        j++;
    }

}
cout<<max(mx1,mx2);


return 0;
}

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:33:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(j>s)
    ^~
school.cpp:36:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     if(used1[b[i].i]==0){
     ^~
school.cpp:51:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(j>m)
    ^~
school.cpp:54:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     if(used2[a[i].i]==0){
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...