# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138293 | 2019-07-29T17:01:36 Z | vince | Detecting Molecules (IOI16_molecules) | C++14 | 2 ms | 380 KB |
#include <stdio.h> #include <math.h> #include <string.h> #include <limits.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <utility> #include <vector> #include <string> #include <unordered_map> #include <map> #include <queue> #include <set> #include <stack> using namespace std; #define long long long #define fi first #define se second typedef pair<int,int> ii; int n; set<ii> st; vector<int> ans; vector<ii> vec; vector<int> find_subset(int l, int u, vector<int> w) { n = w.size(); for(int i = 0; i < w.size(); i++) vec.push_back({w[i], i+1}); sort(vec.begin(), vec.end()); long sum = 0; st.insert({0, n}); for(int i = n-1; i >= 0; i--) { sum += vec[i].fi; st.insert({sum, i}); } auto it = st.lower_bound({l, -1}); if(it != st.end() && it->fi <= u) { for(int i = it->se; i < n; i++) ans.push_back(vec[i].se); return ans; } int pref = 0; for(int i = 0; i < n; i++) { pref += vec[i].fi; st.erase({sum, i}); it = st.lower_bound({l-pref, -1}); if(it != st.end() && it->fi+pref <= u) { for(int j = 0; j <= i; j++) ans.push_back(vec[j].se); for(int j = it->se; j < n; j++) ans.push_back(vec[j].se); return ans; } sum -= vec[i].fi; } return vector<int>(0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
2 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 2 ms | 380 KB | Integer 1 violates the range [0, 0] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Integer 12 violates the range [0, 11] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
2 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 2 ms | 380 KB | Integer 1 violates the range [0, 0] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
2 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 2 ms | 380 KB | Integer 1 violates the range [0, 0] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
2 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 2 ms | 380 KB | Integer 1 violates the range [0, 0] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
2 | Correct | 2 ms | 376 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 2 ms | 380 KB | Integer 1 violates the range [0, 0] |
4 | Halted | 0 ms | 0 KB | - |