标签:http alt efi sort函数 algo 需要 info printf nlogn
如果用sort函数的话需要nlogn的时间复杂度
#include<algorithm> #include<string.h> #include<iostream> #include<stdio.h> #include<string.h> #define OFFSET 500000 int Hash[1000001]; int main() { int n, m; while (scanf_s("%d%d", &n, &m) != EOF) { for (int i = -500000; i <= 500000; i++) Hash[i + OFFSET] = 0; for (int i = 1; i <= n; i++) { int x; scanf_s("%d", &x); Hash[x + OFFSET] = 1; } for (int i = 500000; i >= -500000; i--) { if (Hash[i + OFFSET] == 1) { printf("%d", i); m--; if (m != 0) printf(" "); else { printf("\n"); break; } } } } return 0; }
标签:http alt efi sort函数 algo 需要 info printf nlogn
原文地址:https://www.cnblogs.com/bestluna/p/14473432.html