I wrote the code below to perform few tasks.
Here is my code:
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
int t; cin >> t;
while (t--) {
long long int N; cin >> N;
vector<long long int> cars(N);
for (long long int i = 0; i < N; ++i) {
cin >> cars[i];
}
sort(cars.begin(), cars.end(), greater<long long int>());
long long int profit = 0;
for (long long int i = 0; i < N; ++i) {
if (cars[i]) {
profit += cars[i] - i;
}
}
cout << profit << endl;
}
return 0;
}
I really don't know why I am facing this error while I am submitting the code. Could anyone please help me in getting out of this. Input The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N. The second line contains N space-separated integers P1,P2,…,PN. Output For each test case, print a single line containing one integer ― the maximum profit Chef can make, modulo 1,000,000,007.
Constraints
1≤T≤25
1≤N≤105
0≤Pi≤109 for each valid i
The inputs are
2 next line
3 next line
6 6 6 next line
3 next line
0 1 0
Expected Output
15 next line
1