跳到正文

个人记录

码风进化史

Gambler_Super约 4 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年7月14日
篇幅
约 4 分钟

版本

  1. v2当前
  2. v1

寒武纪:(远古)

C++
#include<bits/stdc++.h>
using namespace std;
int t,w,q[2000010],a[2000010],s[2000010],n,k,i,tmp;
int read(){
	char ch;
	int sum=0,fs;
	ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')	ch=getchar();
	if(ch>='0'&&ch<='9') fs=1;
	else	fs=-1,ch=getchar();
	while(ch>='0'&&ch<='9')	sum=sum*10+ch-'0',ch=getchar();
	return sum*fs;
}
int main(){
	n=read();k=read();
	t=1;w=0;
	for(i=1;i<=n;i++)	a[i]=read();
	for(i=1;i<=n;i++){
		if(i-q[t]+1>k&&t<=w)	++t;
		while(a[q[w]]<=a[i]&&t<=w)	--w;
		q[++w]=i;
		if(i>=k)	s[++tmp]=a[q[t]];
	}
	for(i=1;i<=tmp;i++) 	printf("%d\n",s[i]);
	return 0;
}

奥陶纪:(近代)

C++
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 1, M = 1e5 + 1;
int n, a[N], dp[N][M], sum, ans;
int main() {
	cin >> n; dp[0][0] = 1;
	for(int i = 1; i <= n; i ++)	cin >> a[i], sum += a[i];
	for(int i = 1; i <= n; i ++)
		for(int j = sum; j; j --)
			if(j == a[i]) dp[i][j] = 1;
            else if(dp[i - 1][j]) dp[i][j] = 1;
			else if(dp[i - 1][j + a[i]]) dp[i][j] = 1;
            else if(dp[i - 1][ abs( j - a[i] ) ]) dp[i][j] = 1;
    for(int i = 1; i <= sum; i ++)	if(dp[n][i])	ans ++;
	cout<<ans;
}

志留纪:(现代)

C++
#include <iostream>
#include <algorithm>
#define	fo(i, a, b)	for(int i = a; i <= b; i ++)
#define fp(i, a, b)	for(int i = a; i >= b; i --)
#define IOS ios::sync_with_stdio (0), cin.tie (0), cout.tie (0);
using namespace std;
const int N = 1e2 + 1,M = 2e4 + 1;
int dp[M], a[N][N];
int main() {
	IOS;
	int n, m, h;
	cin >> n >> m >> h;
	fo (i, 1, n)
		fo (j, 1, m)	cin >> a[j][i];
	fo (i, 1, m)	sort(a[i] + 1, a[i] + 1 + n);
	fo (i, 1, m)
		fp(j, h, 0)
			fo(k, 1, n)
				if(j > a[i][k] * 2)	dp[j] = max(dp[j], dp[j - a[i][k] * 2 -1] + i * k);
	int ans = 0;
	fo (i, 0, h)	ans = max(ans, dp[i]);
	cout << ans;
}
原文
抓取于
  1. jiangyixuan120212

    这是“战场”,消灭敌人天经地义

  2. ShiYufan

    “我宁可失去gcxx!”什么!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!果然跟程程说的一样,你**死对头

  3. scc36

    @ Three_bodyIII 震惊!!!文明需要繁衍,你需要gcxx

  4. Gambler_Super

    https://www.luogu.com.cn/discuss/780492?page=4

  5. ShiYufan

    ????? || @Three_bodyIII : 开学延迟到什么时候了?(大喜),我作业还没补完 || @ssSSSss_sunhaojia : 作业™刚补完告诉我开学延迟了

  6. Gambler_Super

    生存是文明的第一需要,我宁可失去gcxx!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  7. ShiYufan

    你没看吗

  8. scc36

    ???

  9. ShiYufan

    看犇犇啊

  10. ShiYufan

    Three_bodyIII自己说的