美团11号笔试第二题

美团第二题,一直0 AC,哪里有问题?
#笔试题目##美团#
全部评论
题理解错了 这是一道阅读理解题
点赞
送花
回复 分享
发布于 2020-10-11 12:56
#include<bits/stdc++.h> using namespace std; int main(){     int n, x;     cin >> n >> x;     vector<int> arr;     for(int i = 0; i < n; i++){         int temp;         cin >> temp;         arr.push_back(temp);     }     sort(arr.begin(), arr.end(), greater<int>());     int count = 0;     int j = x - 1;     if(arr[j] != 0){      while(j + 1 < n && arr[j] == arr[j + 1]){             count++;             j++;     }     }     else{         count--;         while(j - 1 >= 0 && arr[j] == arr[j - 1]){             count--;             j--;         }     }     cout<<x + count<<endl;     return 0; }
点赞
送花
回复 分享
发布于 2020-10-11 13:33
秋招专场
校招火热招聘中
官网直投

相关推荐

点赞 2 评论
分享
牛客网
牛客企业服务