답안 #1071507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071507 2024-08-23T07:56:32 Z vjudge1 Art Exhibition (JOI18_art) C++
10 / 100
4 ms 600 KB
// 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=1e6+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;
	sort(p+1,p+1+n);
	for(int i = 0 ; i < (1 << n) ; i++){
		int mx=0,mn=INF,sm=0;
		for(int j = 0 ; j < n ; j++){
			if(i & (1 << j)){
				mx=max(p[j+1].first,mx);
				if(mn > p[j+1].first) mn=p[j+1].first;
				sm+=p[j+1].second;
			}
		}
		if(ans < sm-(mx-mn) and sm-(mx-mn) != INF) ans=sm-(mx-mn);
	}
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -