标签:alt main tin .com png bit include bsp clu
注意题目条件:a balanced team, 仅保证大家水平差距不超过5即可,不管水平高低
1 #include <bits/stdc++.h> 2 using namespace std; 3 int n,a[200005]; 4 int main() 5 { 6 scanf("%d",&n); 7 for(int i=1;i<=n;i++)scanf("%d",&a[i]); 8 sort(a+1,a+n+1); 9 int j=n,ans=0; 10 for(int i=n;i>=1;i--){ 11 while(a[i]-a[j]<=5 && j>=1) 12 if(a[i]-a[j]<=5){ 13 j--; 14 ans=max(i-j,ans);} 15 } 16 printf("%d\n",ans); 17 }
sorting, two pointers(cf div.3 1113)
标签:alt main tin .com png bit include bsp clu
原文地址:https://www.cnblogs.com/frente/p/10520395.html