Submission #20479

#TimeUsernameProblemLanguageResultExecution timeMemory
20479대신귀여운알파카를드리겠습니다 (#35)복불복 (OJUZ11_luck)C++11
0 / 100
0 ms2020 KiB
#include<bits/stdc++.h> using namespace std; int n, k, a[105], b[105], per[105]; long long ans; 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]); } sort(a+1, a+1+n); sort(b+1, b+1+n); reverse(a+1, a+1+n); if(n <= 8 && k > 1) { for(int i=1;i<=n;i++) per[i] = i; do { int flag = 1; for(int i=1;i<=k;i++) { for(int j=k+1;j<=n;j++) { if(a[i]+b[per[i]] < a[j]+b[per[j]]) { flag = 0; break; } } if(!flag) break; } ans += flag; } while(next_permutation(per+1, per+1+n)); } else if(k == 1) { for(int i=1;i<=n;i++) { long long cur = 1; for(int j=2;j<=n;j++) { long long x; for(x=1;x<=n;x++) { if(a[j] + b[x] > a[1] + b[i]) break; } cur *= max(x-j+1, 0ll); } ans += cur; } } printf("%lld\n",ans); }

Compilation message (stderr)

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