标签:tar contain sort clu ble 暴力 nts test lan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { int n; float p; int num[100010]; scanf( "%d%f" ,&n,&p); for (int i = 0; i < n; i++) scanf( "%d" ,num +i); sort(num, num + n); int ans = 1; for (int i = 0; i < n; i++) for (int j = i + ans; j < n; j++) //从比答案长的结果开始搜 if (num[j] <= num[i] * p) ans = j - i + 1; else //此时都不满足,那后面的max值更大更不可能完成,直接剪掉,如果没加这一步会超时 break ; printf( "%d\n" ,ans); } |
标签:tar contain sort clu ble 暴力 nts test lan
原文地址:http://www.cnblogs.com/zehong1995/p/6399481.html