思路:输入的时候维护一个最小值,按要求输出即可。
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int INF = 1000000005;
int main()
{
//freopen("C:\\Users\\张松超\\Desktop\\in.txt", "r", stdin);
int T, n, m; scanf("%d", &T);
for (int k = 1; k <= T; k++)
{
scanf("%d%d", &n, &m);
printf("Problem %d:\n", k+1000);
int MIN = INF, t;
for (int i = 0; i < n; i++) scanf("%d", &t), MIN = min(MIN, t);
printf("Shortest judge solution: %d bytes.\n", MIN);
MIN = INF;
for (int i = 0; i < m; i++) scanf("%d", &t), MIN = min(MIN, t);
if (MIN == INF) printf("Shortest team solution: N/A bytes.\n");
else printf("Shortest team solution: %d bytes.\n", MIN);
}
return 0;
}
本文介绍了一种通过读取输入并维护最小值来找到最短代码解决方案的方法。该方法适用于两类问题:法官解决方案和团队解决方案。对于每个问题,程序会读取一系列整数并输出最短的有效解决方案长度。
4324

被折叠的 条评论
为什么被折叠?



