加工生产调度
根本不会。。。
http://codevs.cn/problem/3008/
题解:
https://www.cnblogs.com/f91og/p/6024706.html
https://blog.csdn.net/liufeng_king/article/details/8678316
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<vector> 5 using namespace std; 6 #define fi first 7 #define se second 8 #define mp make_pair 9 #define pb push_back 10 typedef long long ll; 11 typedef unsigned long long ull; 12 typedef pair<int,int> pii; 13 struct Q 14 { 15 int x,y,n; 16 }q[1010],ans[1010]; 17 bool operator<(const Q &a,const Q &b) 18 { 19 return min(a.x,a.y)<min(b.x,b.y); 20 } 21 int tl,tr,n; 22 int main() 23 { 24 int i,j,t; 25 scanf("%d",&n);tl=0;tr=n+1; 26 for(i=1;i<=n;i++) scanf("%d",&q[i].x); 27 for(i=1;i<=n;i++) scanf("%d",&q[i].y),q[i].n=i; 28 for(i=1;i<=n;++i) 29 for(j=i+1;j<=n;++j) 30 if(q[j]<q[i]) 31 swap(q[i],q[j]); 32 for(i=1;i<=n;i++) 33 { 34 t=min(q[i].x,q[i].y); 35 if(t==q[i].x) ans[++tl]=q[i]; 36 else ans[--tr]=q[i]; 37 } 38 int tm=0,an=0; 39 for(i=1;i<=n;i++) 40 { 41 tm+=ans[i].x; 42 an=max(an,tm)+ans[i].y; 43 } 44 printf("%d\n",an); 45 return 0; 46 }
http://210.33.19.103/contest/966/problem/2
(玄学数据,不会字典序,然而数据也不是字典序)
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<vector> 5 using namespace std; 6 #define fi first 7 #define se second 8 #define mp make_pair 9 #define pb push_back 10 typedef long long ll; 11 typedef unsigned long long ull; 12 typedef pair<int,int> pii; 13 struct Q 14 { 15 int x,y,n; 16 }q[1010],ans[1010]; 17 bool operator<(const Q &a,const Q &b) 18 { 19 return min(a.x,a.y)<min(b.x,b.y); 20 } 21 int tl,tr,n; 22 int main() 23 { 24 int i,j,t; 25 scanf("%d",&n);tl=0;tr=n+1; 26 for(i=1;i<=n;i++) scanf("%d",&q[i].x); 27 for(i=1;i<=n;i++) scanf("%d",&q[i].y),q[i].n=i; 28 for(i=1;i<=n;++i) 29 for(j=i+1;j<=n;++j) 30 if(q[j]<q[i]) 31 swap(q[i],q[j]); 32 for(i=1;i<=n;i++) 33 { 34 t=min(q[i].x,q[i].y); 35 if(t==q[i].x) ans[++tl]=q[i]; 36 else ans[--tr]=q[i]; 37 } 38 int tm=0,an=0; 39 for(i=1;i<=n;i++) 40 { 41 tm+=ans[i].x; 42 an=max(an,tm)+ans[i].y; 43 } 44 printf("%d\n",an); 45 for(i=1;i<=n;i++) printf("%d ",ans[i].n); 46 return 0; 47 }