跳到正文

题解

P14601 [NWRRC 2025] Bounding Boxes

Refrained约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年11月27日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 1 分钟
题目
P14601

版本

  1. v1当前

签到题。

1. 题目分析

注意到纪念品要放入所有盒子,那么它的三维 W,H,DW,H,D 一定要满足 W≤min⁡{wi},H≤min⁡{hi},D≤min⁡{di}W\leq\min\{w_i\},H\leq\min\{h_i\},D\leq\min\{d_i\},这是相当容易计算的。发现盒子还能旋转,因此输入的 wi,hi,diw_i,h_i,d_i 顺序是可以随意改变的,我们不妨钦定 W≤H≤D,wi≤hi≤diW\leq H\leq D,w_i\leq h_i\leq d_i,那么此时我们就需要用最小值 WW 与 wiw_i 取最小,HH 与 hih_i,DD 与 did_i 比较,尽量使小值不污染较大的值。

2. 代码

C++
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
int main()
{
	int n;
	scanf("%d",&n);
	int w=INF,h=INF,d=INF;
	for(int i=1;i<=n;i++)
	{
		int a[4];
		scanf("%d%d%d",&a[1],&a[2],&a[3]);
		sort(a+1,a+1+3);
		w=min(w,a[1]),h=min(h,a[2]),d=min(d,a[3]);
	}
	printf("%d\n",w*h*d);
	return 0;
}
原文