제출 #493908

#제출 시각아이디문제언어결과실행 시간메모리
493908ahmeterenArt Exhibition (JOI18_art)C++14
10 / 100
5 ms312 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // #ifndef ONLINE_JUDGE // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // #endif ll n, cevap = 0; cin >> n; if(n > 16) return 0; vector<ll> a(n), b(n); for(int i = 0; i < n; i++) cin >> a[i] >> b[i]; for(int i = 0; i < (1 << n); i++) { ll mx = 0, mn = 1e16, sum = 0; for(int j = 0; j < n; j++) { if(i & (1 << j)) { sum += b[j]; mn = min(mn, a[j]); mx = max(mx, a[j]); } } if(mn != 1e16) cevap = max(cevap, sum - (mx - mn)); } cout << cevap << '\n'; 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...