Accepted
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int tc; cin >> tc;
test:
while (tc--) {
ll n; cin >> n;
ll a[n+1], b[n+1];
for (ll i = 1; i <= n; i++) cin >> a[i];
for (ll i = 1; i <= n; i++) cin >> b[i];
ll suffMx[n+2] = {0};
for (ll i = n; i >= 1; i--) suffMx[i] = max(suffMx[i+1], b[i]);
ll ans = 0;
for (ll i = 1; i <= n; i++) ans += max(0LL, suffMx[i] - a[i]);
cout << ans << "\n";
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1228 Business Strategy
- Contest
- LUCC Presents Intra LU Junior Programming Contest - Replay
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-09-02 16:30:47
- Judged At
- 2025-09-02 16:30:47
- Judged By
- Score
- 100
- Total Time
- 19ms
- Peak Memory
- 2.828 MiB