Submission #56556335
Source Code Expand
/*
-------------- | /
| | /
| | /
| * |/ | | ------ *
| | | | / \
| | |\ | | | |\ |
\ | | | \ | | | | \ |
\ | | | \ | | \ / \ |
V | | \ \__/| ----- \ |
*/
#ifdef EMT
#include "Header/stdc++.h"
#else
#include <bits/stdc++.h>
#endif
using namespace std;
#ifdef EMT
#define debug(x) cerr << "\e[1;31m" << #x << " = " << (x) << "\e[0m\n"
#define print(x) emilia_mata_tenshi(#x, begin(x), end(x))
template<typename T, typename T2> ostream& operator<<(ostream &os, const pair<T, T2> &obj) {
return os << '{' << obj.first << ',' << obj.second << '}';
}
template<class TupType, size_t... I> void lamy_kawaii(ostream& os, const TupType& _tup, index_sequence<I...>) {
// source: https://stackoverflow.com/a/41171552
os << '{';
(..., (cerr << (I == 0? "" : ",") << get<I>(_tup)));
os << '}';
}
template<class... T> ostream& operator<<(ostream &os, const tuple<T...>& _tup) {
lamy_kawaii(os, _tup, make_index_sequence<sizeof...(T)>());
return os;
}
template<typename T> void emilia_mata_tenshi(const char *s, T l, T r) {
cerr << "\e[1;33m" << s << " = [";
while (l != r) {
cerr << *l;
cerr << (++l == r ? ']' : ',');
}
cerr << "\e[0m\n";
}
#else
#define debug(x) 48763
#define print(x) 48763
#endif
template<typename T, typename T2> istream& operator>>(istream &is, pair<T, T2> &obj) {
is >> obj.first >> obj.second;
return is;
}
template<typename T> istream& operator>>(istream &is, vector<T> &obj) {
for (auto &x : obj)
is >> x;
return is;
}
#define YN(x) ((x) ? "YES" : "NO")
#define Yn(x) ((x) ? "Yes" : "No")
#define yn(x) ((x) ? "yes" : "no")
#define emilia_my_wife ios::sync_with_stdio(0); cin.tie(NULL);
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
template<typename T>
using base_type = remove_cv_t<remove_reference_t<T>>;
const double EPS = 1e-8;
const int INF = 0x3F3F3F3F;
const ll LINF = 4611686018427387903;
const int MOD = 1e9+7;
static int Lamy_is_cute = []() {
emilia_my_wife
return 48763;
}();
/*--------------------------------------------------------------------------------------*/
signed main() {
int n, k;
cin >> n >> k;
vector<pair<ll, ll>> arr(n);
for (auto &[a, b] : arr)
cin >> a >> b;
sort(arr.begin(), arr.end(), [&] (const auto &x, const auto &y) {
return x.first * (y.first + y.second) + x.second < y.first * (x.first + x.second) + y.second;
});
print(arr);
vector<ll> dp(k + 1);
dp[0] = 1;
for (const auto &[a, b] : arr)
for (int i = k; i; i--)
dp[i] = max(dp[i], dp[i - 1] * a + b);
cout << dp[k] << '\n';
}
Submission Info
Submission Time |
|
Task |
F - Maximum Composition |
User |
JiKuai |
Language |
C++ 20 (gcc 12.2) |
Score |
500 |
Code Size |
3146 Byte |
Status |
AC |
Exec Time |
26 ms |
Memory |
6240 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:45:18: warning: statement has no effect [-Wunused-value]
45 | #define print(x) 48763
| ^~~~~
Main.cpp:87:5: note: in expansion of macro ‘print’
87 | print(arr);
| ^~~~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_maximum_00.txt, 02_maximum_01.txt, 02_maximum_02.txt, 02_maximum_03.txt, 02_maximum_04.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt, 03_handmade_09.txt, 03_handmade_10.txt, 03_handmade_11.txt, 03_handmade_12.txt, 03_handmade_13.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
3416 KiB |
00_sample_01.txt |
AC |
1 ms |
3532 KiB |
01_random_00.txt |
AC |
24 ms |
6184 KiB |
01_random_01.txt |
AC |
23 ms |
5896 KiB |
01_random_02.txt |
AC |
13 ms |
4656 KiB |
01_random_03.txt |
AC |
14 ms |
4656 KiB |
01_random_04.txt |
AC |
19 ms |
5472 KiB |
01_random_05.txt |
AC |
24 ms |
6156 KiB |
01_random_06.txt |
AC |
14 ms |
4836 KiB |
01_random_07.txt |
AC |
18 ms |
5132 KiB |
01_random_08.txt |
AC |
13 ms |
4512 KiB |
01_random_09.txt |
AC |
22 ms |
5940 KiB |
01_random_10.txt |
AC |
17 ms |
5200 KiB |
01_random_11.txt |
AC |
19 ms |
5260 KiB |
01_random_12.txt |
AC |
26 ms |
6212 KiB |
01_random_13.txt |
AC |
23 ms |
6096 KiB |
01_random_14.txt |
AC |
23 ms |
5944 KiB |
02_maximum_00.txt |
AC |
25 ms |
6204 KiB |
02_maximum_01.txt |
AC |
25 ms |
6240 KiB |
02_maximum_02.txt |
AC |
25 ms |
6168 KiB |
02_maximum_03.txt |
AC |
24 ms |
6124 KiB |
02_maximum_04.txt |
AC |
24 ms |
6096 KiB |
03_handmade_00.txt |
AC |
18 ms |
6164 KiB |
03_handmade_01.txt |
AC |
17 ms |
6228 KiB |
03_handmade_02.txt |
AC |
17 ms |
6160 KiB |
03_handmade_03.txt |
AC |
17 ms |
6096 KiB |
03_handmade_04.txt |
AC |
22 ms |
6224 KiB |
03_handmade_05.txt |
AC |
22 ms |
6208 KiB |
03_handmade_06.txt |
AC |
20 ms |
6220 KiB |
03_handmade_07.txt |
AC |
20 ms |
6156 KiB |
03_handmade_08.txt |
AC |
25 ms |
6172 KiB |
03_handmade_09.txt |
AC |
26 ms |
6148 KiB |
03_handmade_10.txt |
AC |
23 ms |
6172 KiB |
03_handmade_11.txt |
AC |
21 ms |
6164 KiB |
03_handmade_12.txt |
AC |
1 ms |
3580 KiB |
03_handmade_13.txt |
AC |
1 ms |
3496 KiB |