当前位置: 代码迷 >> 综合 >> Educational Codeforces Round 95 B Negative Prefixes
  详细解决方案

Educational Codeforces Round 95 B Negative Prefixes

热度:26   发布时间:2024-02-19 15:46:09.0
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 103;int a[N], l[N], b[N];
//将能动的从大到小开始放即可
int main()
{int t;cin >> t;while (t--){int n;cin >> n;for (int i = 1; i <= n; i++)cin >> a[i];for (int j = 1; j <= n; j++)cin >> l[j];int k = 0;for (int i = 1; i <= n; i++)if (l[i] == 0)b[k++] = a[i];sort(b, b + k);k = 0;for (int i = n; i>0; i--)if (l[i] == 0)a[i] = b[k++];for (int i = 1; i <= n; i++)cout << a[i] << ' ';cout << endl;			}return 0;
}

 

  相关解决方案