#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N;
vector<long long int> SizeA={};
vector<long long int> PriceB={};
long long int findS(long long int Amin,long long int Amax){
long long int sum=0;
for(unsigned int i=0;i<SizeA.size();i++){
if(SizeA.at(i)>=Amin && SizeA.at(i)<=Amax) {
sum+=PriceB.at(i);
}
}
return sum;
}
int main() {
cin >> N;
long long int temp,Max=0;
for(int i=0;i<N;i++) {
cin >> temp;
SizeA.push_back(temp);
cin >> temp;
PriceB.push_back(temp);
}
for(unsigned int i=0;i<(SizeA.size());i++){
for(unsigned int j=i;j<SizeA.size();j++){
//cout << i << " " << j << " S is " << findS(min(SizeA.at(i),SizeA.at(j)),max(SizeA.at(i),SizeA.at(j)))<< endl;
//cout <<i<<" "<<j<<endl;
if(true){
temp=findS(min(SizeA.at(i),SizeA.at(j)),max(SizeA.at(i),SizeA.at(j)))-abs(SizeA.at(i)-SizeA.at(j));
if(Max<temp){
Max=temp;
//cout << "New max found "<<Max<<" i is "<<i<<" pointing to "<<SizeA.at(i)<<" j is "<<j<<" pointing to "<<SizeA.at(j)<<" and S is "<<temp<< endl;
}
}
}
}
cout << Max;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
24 ms |
336 KB |
Output is correct |
13 |
Correct |
24 ms |
336 KB |
Output is correct |
14 |
Correct |
25 ms |
336 KB |
Output is correct |
15 |
Correct |
24 ms |
336 KB |
Output is correct |
16 |
Correct |
32 ms |
336 KB |
Output is correct |
17 |
Correct |
24 ms |
336 KB |
Output is correct |
18 |
Correct |
25 ms |
336 KB |
Output is correct |
19 |
Correct |
23 ms |
336 KB |
Output is correct |
20 |
Correct |
24 ms |
336 KB |
Output is correct |
21 |
Correct |
24 ms |
336 KB |
Output is correct |
22 |
Correct |
23 ms |
504 KB |
Output is correct |
23 |
Correct |
24 ms |
336 KB |
Output is correct |
24 |
Correct |
24 ms |
336 KB |
Output is correct |
25 |
Correct |
24 ms |
336 KB |
Output is correct |
26 |
Correct |
24 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
24 ms |
336 KB |
Output is correct |
13 |
Correct |
24 ms |
336 KB |
Output is correct |
14 |
Correct |
25 ms |
336 KB |
Output is correct |
15 |
Correct |
24 ms |
336 KB |
Output is correct |
16 |
Correct |
32 ms |
336 KB |
Output is correct |
17 |
Correct |
24 ms |
336 KB |
Output is correct |
18 |
Correct |
25 ms |
336 KB |
Output is correct |
19 |
Correct |
23 ms |
336 KB |
Output is correct |
20 |
Correct |
24 ms |
336 KB |
Output is correct |
21 |
Correct |
24 ms |
336 KB |
Output is correct |
22 |
Correct |
23 ms |
504 KB |
Output is correct |
23 |
Correct |
24 ms |
336 KB |
Output is correct |
24 |
Correct |
24 ms |
336 KB |
Output is correct |
25 |
Correct |
24 ms |
336 KB |
Output is correct |
26 |
Correct |
24 ms |
336 KB |
Output is correct |
27 |
Execution timed out |
1048 ms |
592 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
24 ms |
336 KB |
Output is correct |
13 |
Correct |
24 ms |
336 KB |
Output is correct |
14 |
Correct |
25 ms |
336 KB |
Output is correct |
15 |
Correct |
24 ms |
336 KB |
Output is correct |
16 |
Correct |
32 ms |
336 KB |
Output is correct |
17 |
Correct |
24 ms |
336 KB |
Output is correct |
18 |
Correct |
25 ms |
336 KB |
Output is correct |
19 |
Correct |
23 ms |
336 KB |
Output is correct |
20 |
Correct |
24 ms |
336 KB |
Output is correct |
21 |
Correct |
24 ms |
336 KB |
Output is correct |
22 |
Correct |
23 ms |
504 KB |
Output is correct |
23 |
Correct |
24 ms |
336 KB |
Output is correct |
24 |
Correct |
24 ms |
336 KB |
Output is correct |
25 |
Correct |
24 ms |
336 KB |
Output is correct |
26 |
Correct |
24 ms |
336 KB |
Output is correct |
27 |
Execution timed out |
1048 ms |
592 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |