pat1085. Perfect Sequence (25)】的更多相关文章

1085. Perfect Sequence (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M <= m * p where M and m…
题目如下: Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M <= m * p where M and m are the maximum and minimum numbers in the sequence, respectively. Now given a sequence an…
题目描写叙述 Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M <= m * p where M and m are the maximum and minimum numbers in the sequence, respectively. Now given a sequence a…
Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respectively. Now given a sequence and a parameter p, you…
题目 Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M <= m * p where M and m are the maximum and minimum numbers in the sequence, respectively. Now given a sequence and a…
题目分析: 意思是要求对于一个给出的数组,我们在其中尽可能多选数字,使得所选数字的max <= min * p,而由于数据量较大直接二层循环不加优化实现是不现实的,由题意得知,对于数字序列的子序列选择没有连续性要求,就是可以随便选的意思,所以我们先将整个序列从小到大排序(这样在遍历时j-i+1就是你选择的个数),从第i == 1个元素开始往后搜索,只要能满足max <= min * p就继续搜索,直到不满足的退出,而在i+1个元素开始搜索时我们发现,由于下标为i+1的元素一定比i大(从小到大排…
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1085 At first, i decide to write the code as follows: /* firstly: sort the array using the algorithm "sort" secondly: traverse all the possible answer and fin…
可以用双指针(尺取法),也可以枚举起点,二分终点. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; int n; long long k; + ]; i…
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> using namespace std; +; long long a[maxn]; int main() { int n,p; scanf("%d %d",&n,&p); ; ;i<n;i++){ scanf(&q…
题意: 输入两个正整数N和P(N<=1e5,P<=1e9),接着输入N个正整数.输出一组数的最大个数使得其中最大的数不超过最小的数P倍. trick: 测试点5会爆int,因为P太大了... AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct node{ long long val; bool flag; }; bool…