Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
134796 | mairuisheng | 加工生产调度 | C++ | 解答错误 | 33 | 0 MS | 272 KB | 634 | 2024-03-02 19:05:55 |
#include<bits/stdc++.h> using namespace std; const int maxn=1000; struct node{int a,b,idx;}e[maxn]; int n,stk[maxn],top; bool cmp(node& x,node &y) { return min(x.a,y.b)<min(x.b,y.a); } void read_and_parse() { scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&e[i].a); for(int i=1;i<=n;i++)scanf("%d",&e[i].b),e[i].idx=i; sort(e+1,e+n+1,cmp); } void solve() { int ta=0,tb=0; for(int i=1;i<=n;i++){ ta+=e[i].a; tb=max(ta,tb)+e[i].b; stk[++top]=e[i].idx; } printf("%d\n",tb); for(int i=1;i<=n;i++)printf("%d%c",stk[i],i==n?'\n':' '); } int main() { read_and_parse(); solve(); return 0; }