/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Accepted 3ms 532.0 KiB
#3 Accepted 2ms 532.0 KiB
#4 Accepted 94ms 1.035 MiB
#5 Accepted 71ms 1.328 MiB
#6 Accepted 72ms 1.188 MiB
#7 Accepted 3ms 532.0 KiB

Code

#include <bits/stdc++.h>

#define ll long long

using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<ll> buy(n), sell(n);
for (int i = 0; i < n; i++){
cin >> buy[i];
}
for (int i = 0; i < n; i++){
cin >> sell[i];
}
for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
    
  }
}
vector<ll> sufMax(n);
sufMax[n - 1] = sell[n - 1];
for (int i = n - 2; i >= 0; i--){
sufMax[i] = max(sell[i], sufMax[i + 1]);
}
ll profit = 0;
for (int i = 0; i < n; i++) {
if (sufMax[i] > buy[i]) {
profit += (sufMax[i] - buy[i]);
}
}

cout << profit << "\n";

}
}

Information

Submit By
Type
Submission
Problem
P1228 Business Strategy
Contest
Testing - Intra LU Programming contest 25
Language
C++17 (G++ 13.2.0)
Submit At
2025-08-30 19:11:48
Judged At
2025-08-30 19:11:48
Judged By
Score
90
Total Time
94ms
Peak Memory
1.328 MiB