完整代码
时间: 2023-07-02 11:12:14 浏览: 73
语音识别完整代码.rar
```cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
#define maxn 1000005
struct node {
char name[10];
int time;
} dz[maxn];
set<string> data;
bool cmp(node a, node b) {
int flag = strcmp(a.name, b.name);
if (flag < 0)
return true;
else if (flag == 0 && a.time > b.time) // 名字相同时按时间从大到小排序
return true;
else
return false;
}
int main() {
int n;
scanf("%d", &n);
char ss[10];
for (int i = 0; i < n; i++) {
scanf("%s", ss);
data.insert(ss);
}
int k;
scanf("%d", &k);
long long sum = 0;
for (int i = 0; i < k; i++) {
int d;
char s[10];
scanf("%s %d", dz[i].name, &d);
dz[i].time = d;
sum += d;
}
sort(dz, dz + k, cmp);
long long pj = sum / k;
int flag = 0;
for (int i = 0; i < k; i++) {
int mark = 1;
if (dz[i].time <= pj)
continue;
if (data.count(dz[i].name))
mark = 0;
if (mark) {
flag = 1;
printf("%s\n", dz[i].name);
}
}
if (flag == 0)
printf("Bei Mei You\n");
return 0;
}
```
阅读全文