제출 #881717

#제출 시각아이디문제언어결과실행 시간메모리
881717alexddSchools (IZhO13_school)C++17
20 / 100
1633 ms4176 KiB
#include<bits/stdc++.h> using namespace std; const int NRIT = 4e7; int n,m,s; pair<int,int> v[300005]; mt19937 rnd(921831); int unde[300005]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>m>>s; for(int i=0;i<n;i++) { cin>>v[i].first>>v[i].second; if(i<m) unde[i]=1; else if(i<m+s) unde[i]=2; } for(int pas=0;pas<NRIT;pas++) { int x = rnd()%n; int y = rnd()%n; if(unde[x]==unde[y]) continue; if(unde[y]==0) swap(x,y); if(unde[x]==0) { if(unde[y]==1) { if(v[x].first - v[y].first > 0) swap(unde[x],unde[y]); } else { if(v[x].second - v[y].second > 0) swap(unde[x],unde[y]); } } else { if(unde[x]==2) swap(x,y); if(v[x].second - v[x].first + v[y].first - v[y].second > 0) { swap(unde[x],unde[y]); } } } long long sum=0; for(int i=0;i<n;i++) { if(unde[i]==1) sum += v[i].first; else if(unde[i]==2) sum += v[i].second; } cout<<sum; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...