#include<bits/stdc++.h>
using namespace std;
const int NRIT = 1e7;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
335 ms |
2496 KB |
Output is correct |
2 |
Correct |
268 ms |
2396 KB |
Output is correct |
3 |
Correct |
332 ms |
2392 KB |
Output is correct |
4 |
Incorrect |
346 ms |
2488 KB |
Output isn't correct |
5 |
Incorrect |
369 ms |
2496 KB |
Output isn't correct |
6 |
Incorrect |
336 ms |
2488 KB |
Output isn't correct |
7 |
Incorrect |
344 ms |
2644 KB |
Output isn't correct |
8 |
Incorrect |
247 ms |
2396 KB |
Output isn't correct |
9 |
Incorrect |
292 ms |
2568 KB |
Output isn't correct |
10 |
Incorrect |
305 ms |
2648 KB |
Output isn't correct |
11 |
Incorrect |
331 ms |
2568 KB |
Output isn't correct |
12 |
Incorrect |
315 ms |
2640 KB |
Output isn't correct |
13 |
Incorrect |
284 ms |
2908 KB |
Output isn't correct |
14 |
Incorrect |
399 ms |
3540 KB |
Output isn't correct |
15 |
Incorrect |
268 ms |
4616 KB |
Output isn't correct |
16 |
Incorrect |
300 ms |
5200 KB |
Output isn't correct |
17 |
Incorrect |
388 ms |
5712 KB |
Output isn't correct |
18 |
Incorrect |
431 ms |
6468 KB |
Output isn't correct |
19 |
Incorrect |
445 ms |
6696 KB |
Output isn't correct |
20 |
Incorrect |
448 ms |
7464 KB |
Output isn't correct |