Submission #847457

# Submission time Handle Problem Language Result Execution time Memory
847457 2023-09-09T16:34:54 Z Lib Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 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 pfx2[200003];
long long check[200003];
long long maxroll[200003]; //maxroll[i]=a <==> de "tra no" 1 khoang toi da =a, can rollback it nhat i vi tri tu loai 1 xuong loai 0
long long minupd[200003]; //minupt[i]=k <==> voi 1 budget<=i; upgrade duoc toi da k vi tri tu loai 1 len loai 2
struct cus{
bool operator()(const long long &x, const long long &y){
	return x>y;
}
};
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;
	cin>>x>>y>>k;
	for(int i=0;i<n-1;i++){
		cin>>U[i]>>V[i]>>W[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;
	int tpos;
	if(mcost>0){
		ans=0;
		for(int i=0;i<n;i++){
			pq.push({-cost1[i],i});
		}
		while(!pq.empty()&&mcost>0){
			mcost+=pq.top().first;
			if(mcost>=0){
			ans++;
			check[pq.top().second]++;
			//cout<<pq.top().second<<" "<<check[pq.top().second]<<" "<<-pq.top().first<<"\n";
			tpos=pq.top().second;
			pq.pop();
			if(check[tpos]==1){
				pq.push({-cost2[tpos],tpos});
			}
			}
		}
		tans=max(tans,ans);
	}
	return tans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:37:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |   ans=0;
      |   ^~~
      |   abs
closing.cpp:54:3: error: 'tans' was not declared in this scope; did you mean 'tanl'?
   54 |   tans=max(tans,ans);
      |   ^~~~
      |   tanl
closing.cpp:56:9: error: 'tans' was not declared in this scope; did you mean 'tanl'?
   56 |  return tans;
      |         ^~~~
      |         tanl