RE求助
查看原帖
RE求助
791222
lby_commandBlock楼主2024/10/4 09:58
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int N = 1e3 + 9;

int n, ans;

vector<int> s;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef BIG_BANANA_A_BIG_BANANA_YOUR_FEEL_VERY_WORDFUL
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		s.push_back(x);
	}
	sort(s.begin(), s.end());
	while (s.size()) {
		int save = s.back();
		printf("save: %d;", save);
		auto a = lower_bound(s.begin(), s.end(), save - 1);
		auto b = upper_bound(s.begin(), s.end(), save - 1);
		printf("索引:(%d,%d);", a - s.begin(), b - s.begin());
		s.erase(a, b);
		printf("删除后: ");
		for (auto i : s)
			cout << i << ' ';
		printf("结束\n");

		s.erase(s.end());
		ans += save;
	}
	cout << ans << endl;
	return 0;
}

测试这组数据时RE:

9
1 1 2 2 3 3 4 4 5

求助!

2024/10/4 09:58
加载中...