/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 3ms 532.0 KiB
#3 Accepted 1ms 364.0 KiB
#4 Accepted 74ms 1.023 MiB
#5 Accepted 69ms 788.0 KiB
#6 Accepted 70ms 1.02 MiB
#7 Accepted 3ms 532.0 KiB
#8 Accepted 55ms 2.02 MiB
#9 Accepted 60ms 2.051 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define endl            '\n'
#define ff              first
#define ss              second
#define debug           cout<<"HERE"<<endl;
void edm()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outputtt.txt","w",stdout);
    #endif
}
void solve()
{
    int n;cin>>n;
    int arr[n+1],brr[n+1];
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=1;i<=n;i++)cin>>brr[i];
    for(int i=n-1;i>0;i--)
    {
        brr[i] = max(brr[i],brr[i+1]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int v1 = arr[i];
        int v2 = brr[i];
        if(v2>v1)
        {
            ans = ans + (v2-v1);
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
    //edm();
    int t = 1;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        // cout<<"Case "<<i<<": ";
        solve();
    }
}

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:53:30
Judged At
2025-09-02 16:53:30
Judged By
Score
100
Total Time
74ms
Peak Memory
2.051 MiB