Submission #20487

#TimeUsernameProblemLanguageResultExecution timeMemory
20487볼빨간민돌이 (#35)복불복 (OJUZ11_luck)C++11
22 / 100
3 ms1120 KiB
#include <cstdio> #include <algorithm> #include <cstdlib> using namespace std; int n, k, a[101], b[101]; const int mod = 1e9+7; void sub1(){ int t[9]; sort(a+1, a+n+1); reverse(a+1, a+n+1); sort(b+1, b+n+1); int ans=0; do{ for(int i=1; i<=n; i++) t[i]=a[i]+b[i]; bool flag=true; for(int i=1; i<=k; i++){ int bigCnt=0; for(int j=1; j<=n; j++) if(t[i] < t[j]) bigCnt++; if(bigCnt+1 > k) flag=false; } for(int i=k+1; i<=n; i++) for(int j=1; j<=k; j++) if(t[i] > t[j]) flag=false; if(flag) ans++; }while(next_permutation(b+1, b+n+1)); printf("%d", ans); exit(0); } void sub2(){ sort(a+1, a+1+n); reverse(a+1, a+1+n); int ans=0; for(int i=1; i<=n; i++){ int x = a[1]+b[i]; int val=1; for(int j=2; j<=n; j++){ int cnt=0; for(int k=1; k<=n; k++){ if(k==i) continue; if(a[j]+b[k] <= x) cnt++; } val=val*1ll*max(cnt-j+2, 0)%mod; } ans=(ans+val)%mod; } printf("%d", ans); 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]); if(n<=8) sub1(); if(k==1) sub2(); return 0; }

Compilation message (stderr)

luck.cpp: In function 'int main()':
luck.cpp:60: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:62:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
luck.cpp:64: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...