比赛 2024暑假C班集训C 评测结果 AAATTTTTTT
题目名称 灯笼 最终得分 30
用户昵称 陆晨洗 运行时间 15.840 s
代码语言 C++ 内存使用 3.53 MiB
提交时间 2024-07-12 10:29:22
显示代码纯文本
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a[100010]={0};
  4. int n,m,x;
  5.  
  6. bool ss(int y,int z)
  7. {
  8. int c,d,i;
  9. bool b[20020]={0};
  10. c=0;d=0;
  11. for(i=y;i<=z;i++)
  12. {
  13. c=c+a[i];
  14. if(b[a[i]+10001]==0)
  15. {
  16. b[a[i]+10001]=1;
  17. d++;
  18. }
  19. }
  20. if(c>=x&&d<=m)
  21. {
  22. return true;
  23. }
  24. else
  25. {
  26. return false;
  27. }
  28. }
  29. int main()
  30. {
  31. freopen("lantern.in","r",stdin);
  32. freopen("lantern.out","w",stdout);
  33. int ans,i,j;
  34. cin>>n>>m>>x;
  35. ans=0;
  36. for(i=1;i<=n;i++)
  37. {
  38. cin>>a[i];
  39. }
  40. for(i=1;i<=n;i++)
  41. {
  42. for(j=i;j<=n;j++)
  43. {
  44. if(ss(i,j)==true)
  45. {
  46. ans=ans+2;
  47. if(i==j)
  48. {
  49. ans--;
  50. }
  51. }
  52. }
  53. }
  54. cout<<ans;
  55. return 0;
  56. }