Submission #20481

#TimeUsernameProblemLanguageResultExecution timeMemory
20481볼빨간민돌이 (#35)복불복 (OJUZ11_luck)C++98
0 / 100
1000 ms1120 KiB
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

int n, k, a[101], b[101];

void sub1(){
	int t[101];
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	sort(b+1, b+n+1);
	int cnt=0;
	do{
		for(int i=1; i<=n; i++)
			t[i]=a[i]+b[i];
		sort(t+1, t+1+n);

		bool flag=true;
		for(int i=1; i<=k; i++){
            if(t+1+n - upper_bound(t+1, t+1+n, a[i]+b[i]) + 1 > k)
				flag=false;
		}
		if(flag) cnt++;
	}while(next_permutation(b+1, b+n+1));
	printf("%d", cnt);
	exit(0);
}

int main(){
	scanf("%d %d", &n, &k);
	for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);
	for(int i=1; i<=n; i++)
		scanf("%d", &b[i]);

	sub1();
	return 0;
}

Compilation message (stderr)

luck.cpp: In function 'int main()':
luck.cpp:31:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
                        ^
luck.cpp:33:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
luck.cpp:35:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &b[i]);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...