Submission #847531

# Submission time Handle Problem Language Result Execution time Memory
847531 2023-09-09T19:33:38 Z Lib Closing Time (IOI23_closing) C++17
35 / 100
64 ms 17496 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
long long pos[200003];
long long cost1[200003];
long long cost2[200003];
long long pfx1[200003];
long long check[200003];
int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
	int n=N;
	int x=X;
	int y=Y;
	long long k=K;
	for(int i=0;i<=200001;i++){
		check[i]=0;
	}
	for(int i=0;i<n-1;i++){
		pos[i+1]=pos[i]+W[i];
	}
	for(int i=0;i<n;i++){
		cost1[i]=min(abs(pos[i]-pos[x]),abs(pos[i]-pos[y]));
		cost2[i]=max(abs(pos[i]-pos[x]),abs(pos[i]-pos[y]))-cost1[i];
		pfx1[i+1]=pfx1[i]+cost1[i];
	}
	priority_queue <pair <long long,int> > pq;
	long long mcost=k;
	long long ans=0,tans=0;
	int tpos;
	//phase 1: chi nang cap cac diem len toi da lv1
	for(int i=0;i<n;i++){
		pq.push({-cost1[i],i});
	}
	ans=0;
	while(mcost>0&&!pq.empty()){
		mcost+=pq.top().first;
		ans++;
		pq.pop();
	}
	if(mcost<0){
		ans--;
	}
	tans=max(tans,ans);
	while(!pq.empty()){
		pq.pop();
	}
	//phase 2: co ca loai 1 lan 2. Khi do, thang loai 2 chi duoc accept khi o day da co 1 roi
	mcost=k;
	mcost-=(pfx1[y+1]-pfx1[x]);
		if(mcost>0){
		ans=0;
		for(int i=0;i<n;i++){
			if(i<x||i>y){
			pq.push({-cost1[i],i});
			}else{
				pq.push({0,i});
			}
		}
		while(!pq.empty()&&mcost>0){
			mcost+=pq.top().first;
			if(mcost>=0){
			ans++;
			tpos=pq.top().second;
			pq.pop();
			check[tpos]++;
			if(check[tpos]==1){
				pq.push({-cost2[tpos],tpos});
			}
			}
		}
		tans=max(tans,ans);
		}
		while(!pq.empty()){
			pq.pop();
		}
	return tans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 17496 KB 1st lines differ - on the 1st token, expected: '451', found: '371'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4852 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4852 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 2 ms 4732 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 2 ms 4696 KB Output is correct
23 Correct 1 ms 4696 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4852 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4952 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 2 ms 4732 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 2 ms 4696 KB Output is correct
23 Correct 1 ms 4696 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 4 ms 4700 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 2 ms 4700 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 4 ms 4952 KB Output is correct
30 Correct 2 ms 4700 KB Output is correct
31 Correct 2 ms 4952 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -