답안 #764249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764249 2023-06-23T09:36:05 Z idkhandle 십자가 놓기 (FXCUP4_cross) C++17
0 / 100
1 ms 340 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using ll = long long;

ll SelectCross(int K, vector<int> I, vector<int> O) {
	int n = I.size();
	vector<pii> a;
	for (int i = 0; i < n; i++) {
		a.emplace_back(I[i], O[i]);
	}
	sort(a.begin(), a.end());

	multiset<int> st;
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (st.size() >= K - 1) {
			auto it = prev(st.end());
			for (int j = 0; j < K - 2; j++) {
				it = prev(it);
			}
			ans = max(ans, a[i].first * (ll)(2 * min(*it, a[i].second) - a[i].first));
		}
		st.insert(a[i].second);
	}
	return ans;
}

Compilation message

cross.cpp: In function 'll SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:19:17: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |   if (st.size() >= K - 1) {
      |       ~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -