Submission #30842

#TimeUsernameProblemLanguageResultExecution timeMemory
30842Kerim학교 설립 (IZhO13_school)C++14
0 / 100
2000 ms3136 KiB
#include "bits/stdc++.h" #define MAXN 100009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} PII arr[MAXN]; bool cmp(PII x,PII y){ return (x.ss-x.ff<y.ss-y.ff); } int main(){ //~ #ifndef ONLINE_JUDGE //~ freopen("file.in", "r", stdin); //~ #endif int n,a,b; scanf("%d%d%d",&n,&a,&b); for(int i=1;i<=n;i++) scanf("%d%d",&arr[i].ff,&arr[i].ss); sort(arr+1,arr+n+1,cmp); ll ans=0; for(int i=a;i<=n-b;i++){ vector<int>a1,a2; for(int j=1;j<=i;j++) a1.pb(arr[j].ff); for(int j=i+1;j<=n;j++) a2.pb(arr[j].ss); sort(all(a1));reverse(all(a1)); sort(all(a2));reverse(all(a2)); ll res=0; for(int j=0;j<a;j++) res+=a1[j]; for(int j=0;j<b;j++) res+=a2[j]; umax(ans,res); } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:29:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&a,&b);
                          ^
school.cpp:31:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&arr[i].ff,&arr[i].ss);
                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...