F - MaratonIME educates

矫情吗;* 2022-05-16 09:04 275阅读 0赞

Statements

USP has many lunch options between all the uni cafeterias and the restaurants inside the campus. An option that is usually chosen by MaratonIME seniors is the restaurant in the School of Education, for its good prices and free jelly.

The seniors have years of experience weighting on their shoulders, and therefore have tired legs. So they choose to go to the restaurant by car. Trying to save gas, the seniors always minimize the number of cars necessary to take everyone to the restaurant.

The seniors asked you to help them solve their problems. This morning, n cars with seniors arrived in the university, and all of them want to go to the restaurant. Each car holds up to 5 people. What is the minimum number of cars necessary to take everyone to the restaurant to “educate”?

Input

On the first line, an integer n, the number of cars. On the second line, n integers a1, …, a**n, how many people arrived in each car.

Limits

  • 1 ≤ n ≤ 105.
  • 1 ≤ a**i ≤ 5, for all i.

Output

Print a single integer, the minimum number of cars needed to take everyone to the restaurant.

Examples

Input

  1. 3
  2. 3 4 5

Output

  1. 3

Input

  1. 6
  2. 1 2 3 4 4 1

Output

  1. 3

题目大意及思路:给你N个车,每个车装a[i]个人,把车上的人相加除以5,有余数直接+1,没余数直接输出。

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main()
  5. {
  6. int n, sum, i;
  7. int a[100100];
  8. scanf("%d", &n);
  9. sum = 0;
  10. for(i = 1; i <= n; i++)
  11. {
  12. scanf("%d", &a[i]);
  13. sum = sum + a[i];
  14. }
  15. if(sum % 5 == 0)
  16. {
  17. printf("%d\n", sum / 5);
  18. }
  19. else
  20. {
  21. printf("%d\n", sum / 5 + 1);
  22. }
  23. return 0;
  24. }

发表评论

表情:
评论列表 (有 0 条评论,275人围观)

还没有评论,来说两句吧...

相关阅读

    相关 【Day01_the importance of EducationEducation?

    各省高考成绩已出,又到一年高考季。张雪峰提到:“普通家庭不要光谈理想,也要谈落地。”志愿怎样填报、选专业还是选学校、什么专业好就业、高考志愿主要看什么?针对这些疑问,你对正在选