-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathL.cpp
160 lines (144 loc) · 4.31 KB
/
L.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
author: Ali
Email: AliGhanbariCs@gmail.com
GitHub: https://github.com/AliBinary
created: 18.11.2024 14:55:58
*/
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define endl '\n'
#define sep ' '
typedef long long ll;
typedef long double ld;
typedef string str;
// pairs
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii> pip;
typedef pair<pii, pii> ppp;
#define F first
#define S second
#define mp make_pair
#define tcT template <class T
tcT > using V = vector<T>;
// vectors
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x));
#define sor_(x) sort(rall(x));
#define rsz resize
#define ins insert
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
#define cpresent(container, element) (find(all(container), element) != container.end()) // vector
// sets
#define present(container, element) (container.find(element) != container.end()) // set/map
#define lb lower_bound
#define ub upper_bound
tcT > int lwb(V<T> &a, const T &b) { return int(lb(all(a), b) - bg(a)); }
tcT > int upb(V<T> &a, const T &b) { return int(ub(all(a), b) - bg(a)); }
// maps
typedef map<int, int> mii;
typedef map<str, int> msi;
// loops
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, b) FOR(i, 0, b)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i, b) ROF(i, 0, b)
#define rep(n) FOR(_, 0, n)
#define each(x, a) for (auto &x : a)
#define tr(it, container) \
for (typeof(container.begin()) it = container.begin(); it != container.end(); ++it)
// debug
#define debug(x) cerr << #x << '=' << (x) << endl;
#define debugp(x) cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define debug2(x, y) cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}" << endl;
#define debugv(v) \
{ \
cerr << #v << " : "; \
for (auto x : v) \
cerr << x << ' '; \
cerr << endl; \
}
#define wall cout << "----------------------------------------\n";
#define kill(x) \
{ \
cout << x << endl; \
return; \
}
// bitwise ops
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return x == 0 ? 0 : 31 - __builtin_clz(x); } // floor(log2(x))
constexpr int p2(int x) { return 1 << x; }
constexpr int msk2(int x) { return p2(x) - 1; }
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); } // divide a by b rounded down
tcT > bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT > bool ckmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; } // set a = max(a,b)
tcT > void remDup(vector<T> &v) { sort(all(v)), v.erase(unique(all(v)), end(v)); } // sort and remove duplicates
bool cmp(pii &a, pii &b) { return (a.second < b.second); }
const int inf = std::numeric_limits<int>::max();
const ll INF = std::numeric_limits<ll>::max();
const ld epsilon = 1. / INF;
void solve();
int main()
{
fast_io;
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
return 0;
}
void solve()
{
int n;
cin >> n;
// if (n == 1)
// kill(2);
int ans = 0;
int a18 = n, a21 = n, a25 = n;
while (a18 > 0 || a21 > 0 || a25 > 0)
{
if (a21 >= 2 && a18 >= 1)
{
ans += 1;
a21 -= 2;
a18 -= 1;
}
else if (a25 >= 2)
{
ans += 1;
a25 -= 2;
}
else if (a18 >= 2)
{
ans += 1;
a18 -= 3;
}
else
{
ans += ceil((a18 + a21 + a25) * 1. / 2);
a18 = 0;
a21 = 0;
a25 = 0;
}
}
kill(ans);
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/