#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int main(){
ll n;
cin >> n;
vector<ll> slots(n);
vector<ll> users(n);
for(ll i = 0; i < n; i++){
cin >> slots[i];
}
for(ll i = 0; i < n; i++){
cin >> users[i];
}
ll happy = 0;
for(ll i = 0; i < n; i++){
for(int j = 0; j < i; j++){
ll x= min(slots[j], users[i]);
slots[j]-=x;
users[i]-=x;
happy+=x;
}
for(int j = i+1; j < n; j++){
ll x= min(slots[j], users[i]);
slots[j]-=x;
users[i]-=x;
happy-=x;
}
ll x= min(slots[i], users[i]);
slots[i]-=x;
users[i]-=x;
}
happy -= accumulate(users.begin(), users.end(), ll(0));
cout << happy;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1094 ms |
4956 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |