#include <stdio.h> #include <stdlib.h> // 比较函数,用于整数的升序排序 int compare(const void *a, const void *b) { int num1 = *(const int *)a; int num2 = *(const int *)b; if (num1 < num2) return -1; else if (num1 > num2) return 1; else return 0; } int main(int argc, char *argv[]) { int n; scanf("%d",&n); int difficulty[n]; for(int i=0;i<n;i++){ scanf("%d",&difficulty[i]); } qsort(difficulty, n, sizeof(int),compare); int add_count=0; int i=0; while(i+2<n){ if(difficulty[i+1]-difficulty[i]<=10 && difficulty[i+2]-difficulty[i+1]<=10) i+=3; else if(difficulty[i+1]-difficulty[i]<=10){ //前两个之间的差值小于10,在后面补充一个题目 add_count++; i+=2; } else if(difficulty[i+1]-difficulty[i]>10 && difficulty[i+1]-difficulty[i]<=20){ //前两个之间的差小于20但是大于10 add_count++; i+=2; } else { add_count+=2; i++; } } if((n-i) !=0 ) add_count+=(3-(n-i)); printf("%d",add_count); return 0; }