제출 #167111

#제출 시각아이디문제언어결과실행 시간메모리
167111abil학교 설립 (IZhO13_school)C++14
100 / 100
281 ms13976 KiB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (3e5 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

pair<int,pair<int,int > > a[N];
multiset<int > st;
long long pr[N], sf[N];

main()
{
	int n, m, s;
	long long sum = 0;
	scanf("%d%d%d", &n, &m, &s);
	for(int i = 1;i <= n; i++){
		scanf("%d%d", &a[i].sc.fr, &a[i].sc.sc);
		a[i].fr = a[i].sc.sc - a[i].sc.fr;
 	}
 	sort(a + 1,a + 1 + n);
 	for(int i = 1;i <= n; i++){
		sum += a[i].sc.fr;
		st.insert(a[i].sc.fr);
		if(i > m){
			sum -= *st.begin();
			st.erase(st.begin());
		}
		pr[i] = sum;
 	}
	st.clear();
	sum = 0;
	for(int i = n;i >= 1; i--){
		sum += a[i].sc.sc;
		st.insert(a[i].sc.sc);
		if(i <= n - s){
			sum -= *st.begin();
			st.erase(st.begin());
		}
		sf[i] = sum;
	}
	long long ans = 0;
	for(int i = max(1, m);i <= n - s; i++){
		ans = max(ans, pr[i] + sf[i + 1]);
	}
	cout << ans;
}

컴파일 시 표준 에러 (stderr) 메시지

school.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
school.cpp: In function 'int main()':
school.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &m, &s);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
school.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a[i].sc.fr, &a[i].sc.sc);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...