Love丶FFC's Blog

CCF-CSP_20190901:小明种苹果

2019-10-27 13:25:36
阅读:1404   •   评论:6
标签:,

编程语言:Python

解题思想:

1.定义足够的变量存储相关的值并进行判断。

2.注意一些细节。

时间复杂度:O(n^2)

IDE代码如下:

  1. N, M = map(int, input().split()) # N:苹果树的棵树,M:疏果操作的轮数
  2. Apple = [[0 for i in range(M + 1)] for j in range(N)] # 初始化苹果列表
  3. # Apple[i][0]代表的是第i棵树初始的苹果数 Apple[i][1-M]代表的是第i棵树疏果的个数
  4. AppleCount = [0 for i in range(N)] # 疏果操作结束后每棵树的苹果个数
  5. Count = 0 # 疏果操作结束后总的苹果个数
  6. Max = 0 # 最多的疏果个数
  7. MaxID = 0 # 疏果个数最多的苹果树的编号
  8. for i in range(N):
  9. Apple[i] = [int(n) for n in input().split()] # 输入一行列表的值
  10. for j in range(M + 1):
  11. AppleCount[i] += Apple[i][j]
  12. Count += AppleCount[i] # 完成T操作
  13. if Apple[i][0] - AppleCount[i] > Max:
  14. Max = Apple[i][0] - AppleCount[i] # 完成P操作
  15. MaxID = i # 完成K操作
  16. elif Apple[i][0] - AppleCount[i] == Max and i < MaxID: # 补充K操作的意外条件
  17. MaxID = i
  18. # 按题目格式进行输出
  19. print(str(Count) + " " + str(MaxID + 1) + " " + str(Max))
  20.  

评论板

共有 6 条评论

  1. Knitant

    online generic cialis View Article PubMed NCBI Google Scholar 73

  2. invoimi

    where to get viagra Hwang is Chief of Breast Surgery at Duke Cancer Institute, Durham, North Carolina

  3. Eakfea

    fenofibrate 200mg sale order fenofibrate 200mg without prescription where can i buy fenofibrate

  4. Yorgbc

    order ketotifen 1mg pills geodon where to buy buy generic imipramine over the counter

  5. Xuwlzt

    purchase mintop without prescription natural ed pills best ed medication

  6. Rkwpdv

    acarbose medication where can i buy prandin griseofulvin 250 mg usa

--------查看该分类下最新文章--------
^
新版博客正在完善中!域名:http://www.loveffc:8080,点击跳转,完全移植后将去除端口号。

Copyright © 2018 - 2021 FFC的小站 - 滇 ICP 备 18010780 号 - 1

- Powered by WordPress & AliYun · Theme by FFC -

- Environment by Windows & XAMPP · Designed by WebStorm & VSCode -

已运行:

访问量:450006