Submission #999484

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9994842024-06-15 15:15:46ef10Knapsack (NOI18_knapsack)C++17
49 / 100
26 ms31828 KiB
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int main() {
LL S, N; cin >> S >> N;
tuple<LL, LL, LL> A[N+1]; memset(A,0,sizeof(A));
for (LL i = 1; i <= N; i++) {
LL v,w,k;
cin >> v >> w >> k;
A[i] = make_tuple(w,v,k);
}
sort(A+1,A+N+1,greater<tuple<LL,LL,LL> >());
LL D[S+1][S+1]; memset(D,0,sizeof(D));
LL ind = 1;
for (LL i = S; i >= 1 && ind <= N; i--) {
if (get<0>(A[ind]) < i) {
i = get<0>(A[ind]);
}
LL id = 1;
while (ind <= N && get<0>(A[ind]) == i) {
for (LL j = 0; j < get<2>(A[ind]) && id <= S; j++) {
D[i][id++] = get<1>(A[ind]);
}
ind++;
if (id > S) break;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:10:48: warning: 'void* memset(void*, int, size_t)' clearing an object of type 'class std::tuple<long long int, long long int, long long int>' with no trivial copy-assignment; use assignment instead [-Wclass-memaccess]
   10 |  tuple<LL, LL, LL> A[N+1]; memset(A,0,sizeof(A));
      |                                                ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from knapsack.cpp:3:
/usr/include/c++/10/tuple:516:11: note: 'class std::tuple<long long int, long long int, long long int>' declared here
  516 |     class tuple : public _Tuple_impl<0, _Elements...>
      |           ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...