Submission #48457

#TimeUsernameProblemLanguageResultExecution timeMemory
48457arman_ferdousArt Exhibition (JOI18_art)C++17
10 / 100
9 ms716 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e5+10; pair<ll,ll> arr[N]; void brute(int n) { ll ans = 0; for(int mask = 1; mask < (1<<n); mask++) { ll sum = 0, mini = (ll)1e18, maxi = (ll)-1e18; for(int i = 0; i < n; i++) if(mask>>i&1) { sum += arr[i].second; mini = min(mini, arr[i].first); maxi = max(maxi, arr[i].first); } ans = max(ans, sum - maxi + mini); } cout << endl << ans << endl; } int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%lld %lld", &arr[i].first, &arr[i].second); /* sort(arr,arr+n); ll ans = 0, sum = 0; for(int i = 0; i < n; i++) { sum += arr[i].second; ans = max(ans, sum - arr[i].first + arr[0].first); } printf("%lld", ans);*/ brute(n); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &arr[i].first, &arr[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...