# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
90750 | YottaByte | 학교 설립 (IZhO13_school) | C++14 | 2057 ms | 5144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define pii pair < int, int >
const int N = 3e5 + 1;
vector < pii > v;
int ans, u[N];
main()
{
int n, m, s;
cin >> n >> m >> s;
for(int i = 1; i <= n; i++)
{
int a, b;
cin >> a >> b;
v.pb( {a, b} );
ans += a;
}
if(m + s == 0)
{
cout << 0 << endl;
return 0;
}
int cnt = n - m - s;
while(s--)
{
int mx = (int)1e8, id = -1;
mx = -mx;
for(int i = 0; i < n; i++)
{
if(u[i] == 0)
{
if(mx < v[i].sc - v[i].fr)
{
mx = v[i].sc - v[i].fr;
id = i;
}
}
}
//cout << id << endl;
u[id] = 1;
ans += mx;
}
while(cnt--)
{
int mn = (int)1e8, id = -1;
for(int i = 0; i < n; i++)
{
if(u[i] == 0)
{
if(mn > v[i].fr)
{
mn = v[i].fr;
id = i;
}
}
}
//cout << id << endl;
u[id] = 1;
ans -= mn;
}
cout << ans << endl;
}
/*
3 1 1
5 2
4 1
6 4
7 2 3
9 8
10 6
3 5
1 7
5 7
6 3
5 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |