Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
34996 A21μΘ_wjy 【S】T4 C++ 运行超时 50 1000 MS 260 KB 1148 2024-11-21 13:31:48

Tests(5/10):


#include<bits/stdc++.h> #define int long long using namespace std; const int maxn=257; int n; struct Node{ int a,b,c; }p[maxn]; inline bool chk(){ for(int i=1;i<n;i++){ if(p[i].a!=p[i+1].a)return 0; if(p[i].b!=p[i+1].b)return 0; } return 1; } int Per[maxn]; Node cur[maxn]; inline void BF(){ for(int i=1;i<=n;i++)Per[i]=i; int ans=1e17; do{ for(int i=1;i<=n;i++)cur[i]=p[Per[i]]; int cst=0; for(int i=2;i<=n;i++){ cst+=max(cur[i-1].a-cur[i].a,0ll); cst+=max(cur[i-1].b-cur[i].b,0ll); cst+=max(cur[i-1].c-cur[i].c,0ll); cur[i].a=max(cur[i].a,cur[i-1].a); cur[i].b=max(cur[i].b,cur[i-1].b); cur[i].c=max(cur[i].c,cur[i-1].c); } ans=min(ans,cst); }while(next_permutation(Per+1,Per+n+1)); cout<<ans<<endl; } signed main(){ // freopen("bakala.in","r",stdin); // freopen("bakala.out","w",stdout); cin>>n; for(int i=1;i<=n;i++)cin>>p[i].a>>p[i].b>>p[i].c; if(chk()){ cout<<0<<endl; return 0; } BF(); }


测评信息: