Submission #394531

#TimeUsernameProblemLanguageResultExecution timeMemory
394531idk321Detecting Molecules (IOI16_molecules)C++11
46 / 100
164 ms532 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int M = 10005; int dp[M]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> res; for (int i = 0; i < M; i++) { dp[i] = -1; } dp[0] = 0; for (int i = 0; i < w.size(); i++) { for (int j = M - 1 - w[i]; j >= 0; j--) { if (dp[j] != -1 && dp[j + w[i]] == -1) { dp[j + w[i]] = i; } } } for (int i = l; i <= u; i++) { if (dp[i] != -1) { int cur = i; while (cur != 0) { res.push_back(dp[cur]); cur -= w[dp[cur]]; } break; } } return res; } /* 7 15 16 5 5 5 5 6 6 6 */

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0; i < w.size(); i++)
      |                     ~~^~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...