QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623808#7617. SpectacleHDU-T12#WA 59ms12204kbC++201.6kb2024-10-09 14:04:062024-10-09 14:04:11

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 14:04:11]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:12204kb
  • [2024-10-09 14:04:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define X first
#define Y second
#define umap unordered_map
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5, mod = 1e9 + 7, maxp = 31, inf = 1e9;
const ll INF = 1e18;
const double eps = 1e-6;

using i64 = long long;

struct Node{
	i64 id1, id2, diff;
	bool operator<(const Node & oth) const{
		return diff > oth.diff;
	}
};

void solve() {
	i64 n;
	cin >> n;
	vector<i64> data(n);
	vector<bool> visited(n);
	for(i64 i = 0; i < n; i++){
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	priority_queue<Node> heap;
	for(int i = 1; i < n; i++){
		heap.push({i - 1, i, data[i] - data[i - 1]});
	}

	vector<i64> result(n + 1, 1e18);
	i64 curK = 0;
	i64 curValue = 0;
	while(not heap.empty()){
		curValue = max(curValue, heap.top().diff);
		i64 id1 = heap.top().id1;
		i64 id2 = heap.top().id2;
		heap.pop();
		if(visited[id1]){
			visited[id1] = false;
			visited[id1 - 1] = false;
			curK--;
		}
		if(visited[id2]){
			visited[id2] = false;
			visited[id2 + 1] = false;
			curK--;
		}

		if(not visited[id1] and not visited[id2]){
			visited[id1] = true;
			visited[id2] = true;
			curK++;
			result[curK] = min(result[curK], curValue);
		}
	}

	for(int i = 1; i <= n / 2; i++){
		cout << result[i] << ' ';
	}
	cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    // cin >> tt;
    while (tt--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

6
100 13 20 14 10 105

output:

1 5 6 

result:

ok single line: '1 5 6 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

2
1 1000000000000000000

output:

999999999999999999 

result:

ok single line: '999999999999999999 '

Test #3:

score: -100
Wrong Answer
time: 59ms
memory: 12204kb

input:

200000
30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 ...

result:

wrong answer 1st lines differ - expected: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...99 9999 10000 10000 10000 10000', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...0000000000 1000000000000000000 '