CSES - Datatähti 2025 alku - Results
Submission details
Task:Tikut
Sender:maweiyin24562
Submission time:2024-10-29 13:21:39 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In member function 'bool Stick::operator<(const Stick&) const':
input/code.cpp:20:24: error: 'E' was not declared in this scope
   20 |                 return E()<other.E();
      |                        ^
input/code.cpp:20:34: error: 'const struct Stick' has no member named 'E'
   20 |                 return E()<other.E();
      |                                  ^

Code

#include <bits/stdc++.h>

using namespace std;

const int N=1000009;
int n,m,a[N];

struct Stick{
	int len,cut;
	int MaxPiece()const {
		return (len%(cut+1)==0?len/(cut+1):len/(cut+1)+1);
	}
	int MinPiece()const {
		return len/(cut+1);
	}
//	double E() const{
//		return (double)(len)/(double)(cut);
//	}
	bool operator <(const Stick&other)const{
		return E()<other.E();
	}
};

Stick s[N];
int Minx=1e9+1;

priority_queue<Stick>pq;

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		Minx=min(Minx,a[i]);
		pq.push((Stick){a[i],0});
	}
	for(int i=1;i<=m;i++){
		Stick now=pq.top();
		pq.pop();
		now.cut++;
		Minx=min(Minx,now.MinPiece());
		pq.push(now);
		cout<<pq.top().MaxPiece()-Minx<<" ";
//		cout<<pq.top().MaxPiece()<<" "<<Minx<<endl;
	}
	return 0;
}