随笔分类 - 排序
摘要:problemsolutioncodes#include#includeusing namespace std;int N,M,ans,n;struct nm{ int Pi; int Ai;}U[5050];bool cmp( const nm a,co...
阅读全文
摘要:problemsolutioncodes#include#includeusing namespace std;struct peo{ int w, id; }hum[50010];bool cmp(peo a, peo b){ return a.w==b.w?a.i...
阅读全文
摘要:NOIP范畴常见的排序一般是这几种 1、冒泡排序,选择排序,插入排序 2、快速排序,归并排序,堆排序 3、计数排序,基数排序,桶排序前两类是基于比较的,第三类是基于统计的。 第一类都是O(N^2)的,第二类都是O(NlogN)的。//冒泡排序//1.相邻的数据两两比较...
阅读全文
摘要:problem多组数据,每组给你一个长为n的序列求该序列的逆序对个数solution对于 i a[j],称a[i]与a[j]构成逆序对。归并合并比较时,对于两个指针i,j :如果a[j] using namespace std;const int maxn = 50...
阅读全文
摘要:problem给你一个n个数的数列找出其中出现超过n/2次的数solution1、既然众数出现了超过了n/2次,那么任意删除序列中的两个不同的数,众数在新序列中出现的次数也一定会超过n/2次。2、所以我们就维护一个计数。碰到自己就累加,反之去掉,为0时就用当前读入更新...
阅读全文
摘要:problemsolutioncodes//模拟即可#include#include#includeusing namespace std;struct node{ int id; string name; int end, peace, paper;/...
阅读全文
摘要:problemsolutioncodes#include#include#includeusing namespace std;string a[30], ans;bool cmp(string a, string b){ return a+b>b+a; }int m...
阅读全文
摘要:problemsolutioncodes#include#include#includeusing namespace std;const int maxn = 5050;struct node{ int id, score; }a[maxn];int cmp(nod...
阅读全文
摘要:solution1、首先行列独立互相不影响,可以单独统计。于是就变成了一个环形纸牌均分问题。 2、纸牌均分问题每行答案是∑i=1n|i∗T/n−G[i]|" role="presentation" style="positio...
阅读全文
摘要:solution直接sort按原声数最大,字幕数第二排序即可。codes#include#includeusing namespace std;const int maxn = 200010;int b[maxn], c[maxn];mapma;//语言i有多少科学家...
阅读全文
摘要://UVa1339 - Ancient Cipher//已AC#include#include#includeint cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int mai...
阅读全文