Submission #40592293
Source Code Expand
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define MP make_pair
#define fs first
#define sc second
using ull = unsigned long long;
using mii = map<int, int>;
using mll = map<ll, ll>;
#define fd(x, e) (x.find(e) != x.end())
#define tcT template <class T
#define tcTU tcT, class U
#define vt vector //tcT > using vt = vector<T>;
#define ar array // tcT, size_t SZ > using ar = array<T, SZ>;
using vi = vt<int>;
using vb = vt<bool>;
using vl = vt<ll>;
using vd = vt<ld>;
using vs = vt<str>;
using vii = vt<pii>;
using vll = vt<pll>;
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(x.begin(), x.end())
#define rsz resize
#define ins insert
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
#define ts to_string
#define ub upper_bound
#define lb lower_bound
tcT> int lwb(vt<T> &a, const T &b) { return int(lb(all(a), b) - bg(a)); }
tcT> int upb(vt<T> &a, const T &b) { return int(ub(all(a), b) - bg(a)); }
#define rp(i, e) for (int (i) = 0; (i) < (int) (e); (i)+=1)
#define rp2(i, a, e) for (int (i) = (a); (i) < (int) (e); (i)+=1)
#define rp3(i, a, e, s) for (int (i) = (a); (i) < (int) (e); (i)+=(s))
#define rpr(i, e) for (int (i) = (e) - 1; i > -1; (i)-=1)
#define rp4(i, a, e) for (int (i) = a; (i) > (int) (e); (i)-=1)
#define rp5(i, a, e, s) for (int (i) = a; (i) > (int) (e); (i)+=(s))
#define E(a, x) for (auto &a: x)
#define nr(a, n) rp(i, n) {cin >> (a)[i];}
#define nr2(a, n, m) rp(i, n) rp(j, m) cin >> (a)[i][j];
#define quick ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const ld PI = acos((ld)-1);
const int dx[4]{1, 0, -1, 0}, dy[4]{0, 1, 0, -1}; // for every grid problem!!
tcT> using pqg = priority_queue<T, vector<T>, greater<T>>;
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr ll pctll(ll x) { return __builtin_popcountll(x); }
constexpr int bits(
int x) { // assert(x >= 0);
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; }
// ------ ------ ------ IO ------ ------ ------ //
template <class A> void re(vt<A>& v);
template <class A, size_t S> void re(array<A, S>& a);
tcT> void re(T& x) {
cin >> x;
}
void re(double& d) {
string t;
re(t);
d=stod(t);
}
void re(long double& d) {
string t;
re(t);
d=stold(t);
}
tcT> void re(pair<T, T> & p) {
T a, b;
re(a);
re(b);
p=make_pair(a, b);
}
template<class H, class... T> void re(H& h, T&... t) {
re(h);
re(t...);
}
template<class A> void re(vt<A>& x) {
for (auto &a: x) re(a);
}
template<class A, size_t S> void re(array<A, S>& x) {
for (auto &a: x) re(a);
}
string to_string(char c) {
return string(1, c);
}
string to_string(bool b) {
return b?"YES":"NO";
}
string to_string(const char* s) {
return string(s); }
string to_string(string s) {
return s;
}
string to_string(vt<bool> v) {
string res;
rp(i, sz(v))
res+=char('0'+v[i]);
return res;
}
template<size_t S> string to_string(bitset<S> b) {
string res;
rp(i, S)
res+=char('0'+b[i]);
return res;
}
tcT> string to_string(pair<T, T> p) {
string res;
res += to_string(p.first);
res += ' ';
res += to_string(p.second);
return res;
}
tcT> string to_string(vt<T> & v) {
bool f=1;
string res;
for (auto& x: v) {
if(!f)
res+=' ';
f=0;
res+=to_string(x);
}
return res;
}
template<class A> void write(A x) {
cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) {
write(h);
write(t...);
}
void print() {
write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) {
write(h);
if(sizeof...(t))
write(' ');
print(t...);
}
void DBG() {
cerr << "]" << endl;
}
template<class H, class... T> void DBG(H h, T... t) {
cerr << to_string(h);
if(sizeof...(t))
cerr << ", ";
DBG(t...);
}
#define wr write
#define ps print
// ------ ------ ------ alg ------ ------ ------ //
tcTU> void sort(vt<T> & a, U f) {
sort(a.begin(), a.end(), f);
}
tcT> void rsor(vt<T> & a) {
sort(a.begin(), a.end(), greater<T>());
}
void rsor(str & a) {
sort(a.begin(), a.end(), greater<char>());
}
tcT> void rev(vt<T> & a){
reverse(a.begin(), a.end());
}
void rev(str & a){
reverse(a.begin(), a.end());
}
#define vmax(x) *max_element(begin(x), end(x))
#define vmin(x) *min_element(begin(x), end(x))
#define umax(x, n) *max_element((x), (x) + (n))
#define umin(x, n) *min_element((x), (x) + (n))
tcT> bool amin(T & a, const T & b) {
return b<a?a=b, 1:0;
}
tcT> bool amax(T & a, const T & b) {
return a<b?a=b, 1:0;
}
tcT> T cdiv(T a, T b) {return (a+b-1)/b;}
tcTU> T ftrue(T lo, T hi, U f) {
while (lo < hi) { T mid = lo+(hi-lo)/2; f(mid) ? hi = mid : lo = mid+1; }
return lo;
}
tcTU> T ltrue(T lo, T hi, U f) {
while (lo < hi) { T mid = lo+(hi-lo+1)/2; f(mid) ? lo = mid : hi = mid-1; }
return lo;
}
#define ri(...) int __VA_ARGS__; re(__VA_ARGS__);
#define rl(...) ll __VA_ARGS__; re(__VA_ARGS__);
#define rs(...) str __VA_ARGS__; re(__VA_ARGS__);
const int mxn = 1e6 + 10;
const int inf = 1e9 + 10;
const int M = 998244353;
void solve() {
ri(n, k);
set<ll> st;
rp(i, n) {
rl(x);
st.ins(x);
}
vl a;
for (auto x: st) {
a.pb(x);
}
n = sz(a);
st.clear();
st.ins(0);
rp(i, k) {
auto x = *st.begin();
st.erase(x);
for (auto u: a) {
st.ins(x + u);
}
}
ps(*st.begin());
return;
}
int main() {
quick;
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
/* 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
*/
Submission Info
Submission Time |
|
Task |
E - Kth Takoyaki Set |
User |
aqxa |
Language |
C++ (GCC 9.2.1) |
Score |
500 |
Code Size |
6214 Byte |
Status |
AC |
Exec Time |
449 ms |
Memory |
50648 KiB |
Compile Error
./Main.cpp: In function ‘std::string to_string(std::vector<bool>)’:
./Main.cpp:51:27: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
51 | #define rp(i, e) for (int (i) = 0; (i) < (int) (e); (i)+=1)
| ^
./Main.cpp:122:2: note: in expansion of macro ‘rp’
122 | rp(i, sz(v))
| ^~
./Main.cpp: In function ‘std::string to_string(std::bitset<_Nb>)’:
./Main.cpp:51:27: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
51 | #define rp(i, e) for (int (i) = 0; (i) < (int) (e); (i)+=1)
| ^
./Main.cpp:128:2: note: in expansion of macro ‘rp’
128 | rp(i, S)
| ^~
./Main.cpp: In function ‘void solve()’:
./Main.cpp:51:27: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
51 | #define rp(i, e) for (int (i) = 0; (i) < (int) (e); (i)+=1)
| ^
./Main.cpp:229:2: note: in expansion of macro ‘rp’
229 | rp(i, n) {
| ^~
./Main.cpp:51:27: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
51 | #define rp(i, e) for (int (i) = 0; (i) < (int) (e); (i)+=1)
| ^
./Main.cpp:241:2: note: in expansion of macro ‘rp’
241 | rp(i, k) {
| ^~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example_00.txt, example_01.txt, example_02.txt |
All |
example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt |
Case Name |
Status |
Exec Time |
Memory |
example_00.txt |
AC |
8 ms |
3656 KiB |
example_01.txt |
AC |
2 ms |
3604 KiB |
example_02.txt |
AC |
328 ms |
19504 KiB |
test_00.txt |
AC |
11 ms |
3732 KiB |
test_01.txt |
AC |
13 ms |
3652 KiB |
test_02.txt |
AC |
15 ms |
3608 KiB |
test_03.txt |
AC |
24 ms |
3684 KiB |
test_04.txt |
AC |
22 ms |
3700 KiB |
test_05.txt |
AC |
27 ms |
3764 KiB |
test_06.txt |
AC |
27 ms |
3660 KiB |
test_07.txt |
AC |
22 ms |
3616 KiB |
test_08.txt |
AC |
27 ms |
3704 KiB |
test_09.txt |
AC |
23 ms |
3688 KiB |
test_10.txt |
AC |
25 ms |
3688 KiB |
test_11.txt |
AC |
23 ms |
3604 KiB |
test_12.txt |
AC |
22 ms |
3632 KiB |
test_13.txt |
AC |
12 ms |
3604 KiB |
test_14.txt |
AC |
12 ms |
3600 KiB |
test_15.txt |
AC |
68 ms |
12960 KiB |
test_16.txt |
AC |
71 ms |
12956 KiB |
test_17.txt |
AC |
2 ms |
3640 KiB |
test_18.txt |
AC |
3 ms |
3656 KiB |
test_19.txt |
AC |
2 ms |
3680 KiB |
test_20.txt |
AC |
119 ms |
7484 KiB |
test_21.txt |
AC |
74 ms |
9860 KiB |
test_22.txt |
AC |
29 ms |
4824 KiB |
test_23.txt |
AC |
14 ms |
4060 KiB |
test_24.txt |
AC |
33 ms |
3820 KiB |
test_25.txt |
AC |
306 ms |
21376 KiB |
test_26.txt |
AC |
366 ms |
26940 KiB |
test_27.txt |
AC |
366 ms |
25168 KiB |
test_28.txt |
AC |
385 ms |
27776 KiB |
test_29.txt |
AC |
449 ms |
36244 KiB |
test_30.txt |
AC |
205 ms |
12832 KiB |
test_31.txt |
AC |
237 ms |
12808 KiB |
test_32.txt |
AC |
213 ms |
12900 KiB |
test_33.txt |
AC |
224 ms |
12836 KiB |
test_34.txt |
AC |
247 ms |
12928 KiB |
test_35.txt |
AC |
331 ms |
50496 KiB |
test_36.txt |
AC |
333 ms |
50640 KiB |
test_37.txt |
AC |
344 ms |
50648 KiB |
test_38.txt |
AC |
313 ms |
50564 KiB |
test_39.txt |
AC |
346 ms |
50648 KiB |