Submission #30842

# Submission time Handle Problem Language Result Execution time Memory
30842 2017-07-27T15:37:07 Z Kerim Schools (IZhO13_school) C++14
0 / 100
2000 ms 3136 KB
#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

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 time Memory Grader output
1 Correct 0 ms 2804 KB Output is correct
2 Correct 0 ms 2804 KB Output is correct
3 Correct 0 ms 2804 KB Output is correct
4 Correct 0 ms 2804 KB Output is correct
5 Correct 0 ms 2804 KB Output is correct
6 Correct 0 ms 2804 KB Output is correct
7 Correct 769 ms 2804 KB Output is correct
8 Correct 3 ms 2944 KB Output is correct
9 Correct 69 ms 2944 KB Output is correct
10 Correct 239 ms 2944 KB Output is correct
11 Correct 289 ms 2948 KB Output is correct
12 Correct 369 ms 2944 KB Output is correct
13 Execution timed out 2000 ms 3136 KB Execution timed out
14 Halted 0 ms 0 KB -