# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042297 | devvikram34 | Knapsack (NOI18_knapsack) | C++17 | 74 ms | 8220 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
// clang-format off
template <class __T1, class __T2>ostream &operator<<( ostream &__X1, const pair<__T1, __T2> &__P1 );template <typename _T1, typename = enable_if_t<!is_same_v<_T1, string> && !is_void_v<typename _T1::value_type>>>ostream &operator<<( ostream &__X1, const _T1 &__V1 ) { if ( &__X1 == &cerr )__X1 << "[ ";bool _1FL = false, _1Bg = true; for ( auto &_G1 : __V1 ) {_1FL = is_same_v<decay_t<decltype( _G1 )>, char> or is_same_v<decay_t<decltype( _G1 )>, long long> or is_same_v<decay_t<decltype( _G1 )>, int>;( !_1FL or _1Bg ) ? __X1 << _G1 : __X1 << ( ( &__X1 == &cerr ) ? ", " : " " ) << _G1; _1Bg = false; } if ( &__X1 == &cerr ) return __X1 << " ].."; return _1FL ? __X1 << '\n' : __X1;}template <class __T1, class __T2>ostream &operator<<( ostream &__X1, const pair<__T1, __T2> &__P1 ) { if ( &__X1 == &cerr ) return __X1 << "<" << __P1.first << ", " << __P1.second << "> "; return __X1 << __P1.first << ' ' << __P1.second;}template <class... Ts>void __prnt( const Ts &..._1AG ) { ( ( cerr << _1AG << " __ " ), ... ); cerr << '\n';}
#define db(...) (cerr << " (:> " << #__VA_ARGS__ << " |= ", __prnt(__VA_ARGS__))
template <class __2T>void __scan( __2T &_2Ti ) { cin >> _2Ti;}template <class __2T, class S>void __scan( pair<__2T, S> &__P2 ) {__scan( __P2.first ), __scan( __P2.second );}template <class __2T>void __scan( vector<__2T> &_2Ti ) { for ( auto &i : _2Ti )__scan( i );}template <typename... _1VL>void in( _1VL &..._4W ) {( __scan( _4W ), ... );}template <typename _1T>void out( const _1T &_1Ar ) {if constexpr ( is_same_v<_1T, char> )( _1Ar == '\n' ) ? cout << _1Ar << "" : cout << _1Ar << " ";else if constexpr ( is_same_v<_1T, int> or is_same_v<_1T, long long> or is_same_v<_1T, string> )cout << _1Ar << " "; else cout << _1Ar << "";}template <typename... Args>void out( const Args &...args ) { ( out( args ), ... );}
// clang-format on
#define all(vls) vls.begin( ), vls.end( )
#define int long long
#define ll long long
const ll md = 1000000007, inf = (ll)2e16, N = (ll)1e6;
void __( ) {
int s, n;
in(s, n);
vector<vector<int>> a(n, vector<int>(3));
for ( auto &&i : a ) {
in(i[0], i[1], i[2]);
i[2] = min(i[2], s / i[1]);
}
sort(a.begin( ), a.end( ), [&](vector<int> &l, vector<int> &r) {
return (l[1] < r[1]) ? true : (l[1] == r[1]) ? l[0] > r[0] : false;
});
// db(a);
int d = 0, p = 0;
vector<pair<int, vector<int>>> v;
for ( auto &&i : a ) {
if ( p != i[1] ) {
d = 0;
v.push_back({i[1], {}});
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |