QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#764686 | #7964. 转化 | yzy_21# | TL | 0ms | 0kb | C++14 | 1.2kb | 2024-11-20 10:12:18 | 2024-11-20 10:12:21 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;cin >> n;
vector<int> a(n + 1), b(n + 1), c(n + 1);
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) cin >> c[i];
set<int> st;
set<pii, greater<pii>> st2;
for(int i = 1; i <= n; ++i) {
if(a[i] != 0) {
a[i] += c[i];
c[i] = 0;
st.insert(i);
}
else st2.insert({c[i], i});
}
while(st.size() and st2.size()) {
int i = *st.begin();
int j = st2.begin()->second;
if(a[i] > 1) {
a[i]--;
a[j] = c[j] + 1;
c[j] = 0;
}
else st.erase(st.begin());
}
int ans = 0, sum = 0;
for(int i = 1; i <= n; ++i) {
int x = min(a[i], b[i]);
sum += min(a[i], b[i]);
ans += a[i];
a[i] -= x;
}
for(int i = 1; i <= n; ++i) {
cout << sum + a[i] << " ";
}
cout << "\n";
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
351493 0 37836791 46095966 46912389 21595941 0 3 86568894 3 0 0 0 0 39910208 0 2 4 86885825 1 67660833 0 24488082 52447896 0 67190942 70457491 11166998 90470470 11095822 0 0 5 47222930 2 49736354 0 0 0 77339472 0 5 3 0 25347727 0 3 2 0 48844622 0 65142757 1 73733079 80634668 46683173 0 31644647 9760...