/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Wrong Answer 45ms 580.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++){
    if(sell[i]>sell[j]) swap(sell[i],sell[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-31 16:23:16
Judged At
2025-08-31 16:23:16
Judged By
Score
0
Total Time
45ms
Peak Memory
580.0 KiB