제출 #1071240

#제출 시각아이디문제언어결과실행 시간메모리
1071240vjudge1Art Exhibition (JOI18_art)C++98
0 / 100
4 ms348 KiB
// Balgabaev Mansur
#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define pb push_back
#define int long long


using namespace std;

const int N=1e5+7;
const int MOD=1e9+7;
const int INF=1e18;

int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}

pair<int,int>p[N];

void solve(){
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> p[i].first >> p[i].second;
	}
	int ans=0;
	for(int i = 0 ; i < (1 << n) ; i++){
		int mxsz=0,mnsz=INF,sm=0;
		for(int j = 0 ; j < n ; j++){
			if(i & (1 << j)){
				mxsz=max(mxsz,p[j+1].first);
				mnsz=min(mnsz,p[j+1].first);
				sm+=p[j].second;
			}
		}
		ans=max(ans,(sm-(mxsz-mnsz)));
	}
	cout << ans;
}	
 
signed main() {
   // freopen("closing.in", "r", stdin);
   // freopen("closing.out", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int test = 1,cntx=1;
    //cin >> test;
    while (test--) {
	//cout << "Case " << 	cntx << ':' << '\n';
        solve();
        cntx++;
	}		
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...