求助

P1631 序列合并

```cpp #include<bits/stdc++.h> using namespace std; int m[100010],n[100010]; struct node { int x,y,z; bool operator < (const node &a) const { return z>a.z; } }; struct dode { int x,y; bool operator < (const dode &a) const { return x>a.x;} }; set<dode> s; priority_queue <node> q; int main() { int a; cin >> a; for (int i=1;i<=a;i++) scanf("%d",&m[i]); for (int i=1;i<=a;i++) scanf("%d",&n[i]); { q.pop(); cout << u.x << " " << u.y << " " << u.z << endl; int xx=u.x,yy=u.y; if (xx!=a) if (s.find((dode){xx+1,yy})==s.end()) { q.push((node){xx+1,yy,m[xx+1]+n[yy]}); s.insert((dode){xx+1,yy}); } if (yy!=a) if (s.find((dode){xx,yy+1})==s.end()) { q.push((node){xx,yy+1,m[xx]+n[yy+1]}); s.insert((dode){xx,yy+1}); } } return 0; } ```
by Hide_on_bush @ 2018-10-07 20:48:48


@[Hide_on_bush](/space/show?uid=39416) 现场捕捉zyk大佬
by RKcer21 @ 2018-10-07 21:13:48


@[俞科chen21](/space/show?uid=56090) ++
by 为依相逢 @ 2018-10-07 21:20:53


@[Hide_on_bush](/space/show?uid=39416) 你这个有点麻烦 我是这样打的: ```cpp #include<bits/stdc++.h> using namespace std; priority_queue< int,vector<int>,greater<int> >q; int n,a[100001],b[100001]; int main() { ios::sync_with_stdio; cin >> n; for (int i=1; i<=n; i++) cin >> a[i]; for (int i=1; i<=n; i++) cin >> b[i]; for (int i=1; i<=n; i++) for (int j=1; (j-1)*(i-1)<=n&&j<=n; j++) q.push(a[i]+b[j]); for (int i=1; i<=n; i++) { cout << q.top() << " "; q.pop(); } } ``` ##### 用优先队列就行了
by Red_Bands_whk @ 2018-10-07 22:16:20


题解?@[RedBands](/space/show?uid=49450)
by Hide_on_bush @ 2018-10-07 23:02:50


@[Hide_on_bush](/space/show?uid=39416) ...
by 为依相逢 @ 2018-10-08 12:44:09


FAKE我自己打的堆
by Red_Bands_whk @ 2018-10-08 20:54:30


|