let's start Code

Cut the sticks

Problem link: Cut the sticks


#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
int main()
{
FASTIO
/*
//double start_time = clock();
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
//*/
int T;
//cin >> T;
T = 1;
for (int cs = 1; cs <= T; cs++) {
int n;
cin >> n;
priority_queue <int, vector<int>, greater<int> > PQ;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
PQ.push(x);
}
cout << n << endl;
while (!PQ.empty()) {
int tp = PQ.top();
PQ.pop();
vector<int> v;
while (!PQ.empty()) {
int x = PQ.top();
PQ.pop();
x -= tp;
if (x > 0) v.push_back(x);
}
for (auto x : v) PQ.push(x);
int ans = PQ.size();
if (ans > 0) cout << ans << endl;
}
}
//double end_time = clock();
//printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
return 0;
}
view raw 1.cpp hosted with ❤ by GitHub
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
int main()
{
FASTIO
///*
//double start_time = clock();
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
//*/
int T;
//cin >> T;
T = 1;
for (int cs = 1; cs <= T; cs++) {
int n;
cin >> n;
vector<int> v(n + 1);
for (int i = 1; i <= n; i++) cin >> v[i];
sort(v.begin(), v.end());
cout << n << endl;
for (int i = 1; i < n; i++) {
if (v[i] != v[i + 1]) {
cout << (n - i) << endl;
}
}
}
//double end_time = clock();
//printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
return 0;
}
view raw 2.cpp hosted with ❤ by GitHub
Share:

Related Posts:

No comments:

Post a Comment

About

let's start CODE

Popular Posts