#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n ;
cin>>n ;
long long arr[n] , arr1[n] ;
for(long long i = 0 ; i < n ; ++i)
cin>>arr[i]>>arr1[i] ;
long long ans = 0 ;
for(long long i = 1 ; i < (1 << n) ; ++i)
{
long long sum = 0 , MAX = 0 , MIN = 1e18 ;
for(long long j = 0 ; j < n ; ++j)
{
if(i & (1 << j))
{
sum += arr1[j] ;
MAX = max(MAX , arr[j]);
MIN = min(MIN , arr[j]);
}
}
ans = max(ans , sum - (MAX - MIN));
}
return cout<<ans , 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
484 KB |
Output is correct |
3 |
Correct |
9 ms |
484 KB |
Output is correct |
4 |
Correct |
7 ms |
484 KB |
Output is correct |
5 |
Correct |
7 ms |
484 KB |
Output is correct |
6 |
Correct |
7 ms |
484 KB |
Output is correct |
7 |
Correct |
7 ms |
484 KB |
Output is correct |
8 |
Correct |
7 ms |
484 KB |
Output is correct |
9 |
Correct |
7 ms |
540 KB |
Output is correct |
10 |
Correct |
7 ms |
564 KB |
Output is correct |
11 |
Correct |
18 ms |
564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
484 KB |
Output is correct |
3 |
Correct |
9 ms |
484 KB |
Output is correct |
4 |
Correct |
7 ms |
484 KB |
Output is correct |
5 |
Correct |
7 ms |
484 KB |
Output is correct |
6 |
Correct |
7 ms |
484 KB |
Output is correct |
7 |
Correct |
7 ms |
484 KB |
Output is correct |
8 |
Correct |
7 ms |
484 KB |
Output is correct |
9 |
Correct |
7 ms |
540 KB |
Output is correct |
10 |
Correct |
7 ms |
564 KB |
Output is correct |
11 |
Correct |
18 ms |
564 KB |
Output is correct |
12 |
Incorrect |
6 ms |
612 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
484 KB |
Output is correct |
3 |
Correct |
9 ms |
484 KB |
Output is correct |
4 |
Correct |
7 ms |
484 KB |
Output is correct |
5 |
Correct |
7 ms |
484 KB |
Output is correct |
6 |
Correct |
7 ms |
484 KB |
Output is correct |
7 |
Correct |
7 ms |
484 KB |
Output is correct |
8 |
Correct |
7 ms |
484 KB |
Output is correct |
9 |
Correct |
7 ms |
540 KB |
Output is correct |
10 |
Correct |
7 ms |
564 KB |
Output is correct |
11 |
Correct |
18 ms |
564 KB |
Output is correct |
12 |
Incorrect |
6 ms |
612 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
484 KB |
Output is correct |
3 |
Correct |
9 ms |
484 KB |
Output is correct |
4 |
Correct |
7 ms |
484 KB |
Output is correct |
5 |
Correct |
7 ms |
484 KB |
Output is correct |
6 |
Correct |
7 ms |
484 KB |
Output is correct |
7 |
Correct |
7 ms |
484 KB |
Output is correct |
8 |
Correct |
7 ms |
484 KB |
Output is correct |
9 |
Correct |
7 ms |
540 KB |
Output is correct |
10 |
Correct |
7 ms |
564 KB |
Output is correct |
11 |
Correct |
18 ms |
564 KB |
Output is correct |
12 |
Incorrect |
6 ms |
612 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |