Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
150966 lrf820215 加工生产调度 C++ 编译错误 0 0 MS 0 KB 733 2024-06-10 10:23:23

Tests(0/0):


#include<bits\stdc++.h> using namespace std; int N=5; int a[5]={3,8,4,9,6}; int b[5]={6,2,10,7,5}; int best[5]; struct NodeType{ int no; bool group; int time; bool operator<(const NodeType &s)const{ return time<s.time; } }; int solve(){ int i,j,k; NodeType c[N]; for(i=0;i<N;i++){ c[i].no=i; c[i].group=(a[i]<=b[i]); c[i].time=a[i]<=b[i]?a[i]:b[i]; } sort(c,c+N); j=0;k=N-1; for(i=0;i<N;i++){ if(c[i].group==1) best[j++]=c[i].no; else best[k--]=c[i].no; } int T1=0; int T2=0; for(i=0;i<N;i++){ T1+=a[best[i]]; T2=max(T1,T2)+b[best[i]]; } return T2; } int main(){ cout<<solve()<<endl; for(int i=0;i<N;i++){ printf("%d ",best[i]+1); } return 0; }


测评信息: