제출 #1071247

#제출 시각아이디문제언어결과실행 시간메모리
1071247vjudge1Art Exhibition (JOI18_art)C++17
10 / 100
5 ms600 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define lld long double #define pb push_back #define pf push_front #define F first #define S second #define all(a) a.begin(),a.end() #define IShowSpeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); const int N=5e5+10; const int K=505; const int mod=1e9+7; const ll inf=1e18+228; const int dx[]={-1,0,0,1}; const int dy[]={0,-1,1,0}; struct node { ll a,b; }h[N]; bool cmp(node a, node b){ if(a.a == b.a) return a.b < b.b; return a.a < b.a; } int main() { IShowSpeed ll n,ans=0; cin>>n; for(int i=1;i<=n;i++) cin>>h[i].a>>h[i].b; sort(h+1,h+n+1,cmp); for(int i=1;i<(1 << n);i++) { ll mx=0,mn=inf,s=0; for(int j=0;j<n;j++) { int b = (i >> j) & 1; if(b) { mn=min(mn,h[j+1].a); mx=max(mx,h[j+1].a); s+=h[j+1].b; } } ans=max(ans,s-(mx-mn)); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...