Codeforces Round #402 (Div. 2) C:Dishonest Sellers

Codeforces Round #402 (Div. 2) C:Dishonest Sellers

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
#define MAXN 200010
static int N,K,ans,A[MAXN],B[MAXN];
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++)//贪心  
		scanf("%d", &A[i]), ans += A[i];//先全选A 然后再选B 选B时,可以b-a+ans 就行了//这样就间接的选择了B 
	for (int i = 1; i <= N; i++)
		scanf("%d", &B[i]), B[i]-=A[i];
	sort(B + 1, B + N + 1);
	for (int i = 1; i<=N-K&&B[i]<0; i++)//B[i]<0表示B


你可能感兴趣的:(coderforce)