제출 #1321775

#제출 시각아이디문제언어결과실행 시간메모리
1321775camil7Art Exhibition (JOI18_art)C++20
10 / 100
4 ms420 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define int long long #define ull unsigned long long #define lb lower_bound #define ub upper_bound void solve() { int n; cin >> n; int a[n], b[n]; for (int i = 1; i <= n; i++){ cin >> a[i - 1] >> b[i - 1]; } int ans = 0; for (int mask = 0; mask < (1 << n); mask++){ int sum = 0; int mn = LLONG_MAX; int mx = LLONG_MIN; for (int i = 0; i < n; i++){ if((mask & (1 << i))){ mn = min(mn, a[i]); mx = max(mx, a[i]); sum += b[i]; } } ans = max(ans, sum - (mx - mn)); } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...