题目: 有 \(n\) 个整数,将其分配给 \(k\) 个人,每个人要求获得的数的个数为 \(w[i]\),每个人的幸福值为受的数的最大值和最小值之和。求所有人幸福值的和的最大值。 $1≤n≤2?105,1≤k≤n,?109≤a_i≤10^9,1≤w_i≤n,w_1+w_2+…+w_k=n$ 分析: ...
分类:
其他好文 时间:
2020-06-25 17:27:51
阅读次数:
80
1.串的存储结构 typedef struct{ char str[MaxSize+1];//末尾+'\0' int length; }Strfix; //变长存储结构 typedef struct{ char *ch; int length; }StrNonfix; StrNonfix S; S. ...
分类:
其他好文 时间:
2020-06-25 12:09:03
阅读次数:
194
#include <stdio.h> #include <stdlib.h> #define LEN sizeof(struct node) typedef struct node{ int data; struct node *next; }List; List *selectsort(List ...
分类:
其他好文 时间:
2020-06-25 10:12:54
阅读次数:
53
1. 概念 原子操作是指不被打断的操作,即它是最小的执行单位。最简单的原子操作就是一条条的汇编指令(不包括一些伪指令,伪指令会被汇编器解释成多条汇编指令)。在 linux 中原子操作对应的数据结构为 atomic_t,定义如下: typedef struct { int counter; } ato ...
分类:
其他好文 时间:
2020-06-24 19:57:50
阅读次数:
57
迪杰斯特拉算法 时间复杂度O(n3) 1 typedef int Patharc[MAXVEX]; /* 用于存储最短路径下标的数组 */ 2 typedef int ShortPathTable[MAXVEX];/* 用于存储到各点最短路径的权值和 */ 3 4 #define MAXVEX 9 ...
分类:
其他好文 时间:
2020-06-24 19:19:41
阅读次数:
54
记录下来,以后用到了直接照抄。 代码 #include <stdio.h> #include <stdlib.h> typedef struct node { struct node *next; int value; } *SingleList; int value_compare(struct ...
分类:
编程语言 时间:
2020-06-24 12:03:09
阅读次数:
40
原题链接 KMP模板:AC,858ms,13112KB内存 消耗太大了 #include<bits/stdc++.h> using namespace std; using namespace std; #define ms(x, n) memset(x,n,sizeof(x)); typedef ...
分类:
其他好文 时间:
2020-06-23 20:53:37
阅读次数:
66
1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 typedef bitset<10000> bint; 6 inline bint plus(bint a,bint b){ ...
分类:
其他好文 时间:
2020-06-23 11:39:02
阅读次数:
66
题目传送门:AtCoder Grand Contest 005。 A - STring 括号匹配。 #include <cstdio> const int MN = 200005; char s[MN], t[MN]; int tp; int main() { scanf("%s", s + 1); ...
分类:
其他好文 时间:
2020-06-23 00:47:22
阅读次数:
71
题目链接:https://www.acwing.com/problem/content/201/ 求k对1-n所有数取模的和。 证明一段可以作为等差数列来求,证明如下:(转自ACwing) 代码如下: #include<iostream> using namespace std; typedef l ...
分类:
编程语言 时间:
2020-06-22 22:26:30
阅读次数:
54