제출 #168280

#제출 시각아이디문제언어결과실행 시간메모리
168280juggernaut학교 설립 (IZhO13_school)C++14
20 / 100
221 ms8568 KiB
#include<bits/stdc++.h> #define int long long int using namespace std; int n,a,b,i,c1,c2; pair<int,int>v[300001]; bool fr(pair<int,int>l,pair<int,int>r){ return l.first>r.first||l.first==r.first&&l.second<r.second; } bool sc(pair<int,int>l,pair<int,int>r){ return l.second>r.second||l.second==r.second&&l.first<r.first; } main(){ scanf("%lld%lld%lld",&n,&a,&b); for(i=1;i<=n;i++)scanf("%lld%lld",&v[i].first,&v[i].second); sort(v+1,v+1+n,fr); for(i=1;i<=a;i++)c1+=v[i].first; sort(v+1+a,v+1+n,sc); for(i=a+1;i<=a+b;i++)c1+=v[i].second; sort(v+1,v+1+n,sc); for(i=1;i<=b;i++)c2+=v[i].second; sort(v+1+b,v+1+n,fr); for(i=b+1;i<=a+b;i++)c2+=v[i].first; cout<<max(c1,c2); }

컴파일 시 표준 에러 (stderr) 메시지

school.cpp: In function 'bool fr(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
school.cpp:7:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     return l.first>r.first||l.first==r.first&&l.second<r.second;
                             ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
school.cpp: In function 'bool sc(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
school.cpp:10:49: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     return l.second>r.second||l.second==r.second&&l.first<r.first;
                               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
school.cpp: At global scope:
school.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
school.cpp: In function 'int main()':
school.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld",&n,&a,&b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++)scanf("%lld%lld",&v[i].first,&v[i].second);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...