# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172476 | 2020-01-01T16:08:32 Z | gs18103 | Detecting Molecules (IOI16_molecules) | C++14 | 2 ms | 380 KB |
#include "molecules.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define em emplace #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int MAX = 505050; const int INF = INT_MAX >> 1; const ll LINF = LLONG_MAX >> 1; const ll mod = 1e9+9; vector<int> find_subset(int l, int u, vector<int> w) { vector <int> ans; vector <pll> W; for(int i = 0; i < w.size(); i++) W.eb(w[i], i); sort(all(W)); ll sumh = 0, suml = 0, U = u, L = l; for(int i = 1; i <= W.size(); i++) { sumh += W[W.size()-i].fi, suml += W[i-1].fi; if(sumh >= U && suml <= U) { if(suml >= L) { for(int j = 0; j < i; j++) { ans.eb(W[j].se); } break; } for(int j = 0; j + i < W.size(); j++) { ll tsum = suml - W[j].fi + W[j+i].fi; if(tsum >= L && tsum <= U) { for(int k = 0; k < i; k++) { ans.eb(W[j+k+1].se); } break; } } break; } if(sumh >= L && suml <= L) { if(sumh <= u) { for(int j = 0; j < i; j++) { ans.eb(W[W.size()-1-j].se); } break; } for(int j = 0; j + i < W.size(); j++) { ll tsum = sumh - W[W.size()-1-j].fi + W[W.size()-1-j-i].fi; if(tsum >= L && tsum <= U) { for(int k = 0; k < i; k++) { ans.eb(W[j-k-1].se); } break; } } break; } } return ans; }
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 | Correct | 2 ms | 252 KB | OK (n = 1, answer = YES) |
4 | Correct | 2 ms | 256 KB | OK (n = 2, answer = YES) |
5 | Correct | 2 ms | 376 KB | OK (n = 2, answer = YES) |
6 | Correct | 2 ms | 296 KB | OK (n = 3, answer = YES) |
7 | Correct | 1 ms | 376 KB | OK (n = 3, answer = YES) |
8 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
9 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
10 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
11 | Correct | 2 ms | 380 KB | OK (n = 3, answer = YES) |
12 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
13 | Correct | 2 ms | 256 KB | OK (n = 3, answer = NO) |
14 | Incorrect | 2 ms | 256 KB | Contestant can not find answer, jury can |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Contestant can not find answer, jury can |
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 | Correct | 2 ms | 252 KB | OK (n = 1, answer = YES) |
4 | Correct | 2 ms | 256 KB | OK (n = 2, answer = YES) |
5 | Correct | 2 ms | 376 KB | OK (n = 2, answer = YES) |
6 | Correct | 2 ms | 296 KB | OK (n = 3, answer = YES) |
7 | Correct | 1 ms | 376 KB | OK (n = 3, answer = YES) |
8 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
9 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
10 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
11 | Correct | 2 ms | 380 KB | OK (n = 3, answer = YES) |
12 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
13 | Correct | 2 ms | 256 KB | OK (n = 3, answer = NO) |
14 | Incorrect | 2 ms | 256 KB | Contestant can not find answer, jury can |
15 | 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 | Correct | 2 ms | 252 KB | OK (n = 1, answer = YES) |
4 | Correct | 2 ms | 256 KB | OK (n = 2, answer = YES) |
5 | Correct | 2 ms | 376 KB | OK (n = 2, answer = YES) |
6 | Correct | 2 ms | 296 KB | OK (n = 3, answer = YES) |
7 | Correct | 1 ms | 376 KB | OK (n = 3, answer = YES) |
8 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
9 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
10 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
11 | Correct | 2 ms | 380 KB | OK (n = 3, answer = YES) |
12 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
13 | Correct | 2 ms | 256 KB | OK (n = 3, answer = NO) |
14 | Incorrect | 2 ms | 256 KB | Contestant can not find answer, jury can |
15 | 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 | Correct | 2 ms | 252 KB | OK (n = 1, answer = YES) |
4 | Correct | 2 ms | 256 KB | OK (n = 2, answer = YES) |
5 | Correct | 2 ms | 376 KB | OK (n = 2, answer = YES) |
6 | Correct | 2 ms | 296 KB | OK (n = 3, answer = YES) |
7 | Correct | 1 ms | 376 KB | OK (n = 3, answer = YES) |
8 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
9 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
10 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
11 | Correct | 2 ms | 380 KB | OK (n = 3, answer = YES) |
12 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
13 | Correct | 2 ms | 256 KB | OK (n = 3, answer = NO) |
14 | Incorrect | 2 ms | 256 KB | Contestant can not find answer, jury can |
15 | 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 | Correct | 2 ms | 252 KB | OK (n = 1, answer = YES) |
4 | Correct | 2 ms | 256 KB | OK (n = 2, answer = YES) |
5 | Correct | 2 ms | 376 KB | OK (n = 2, answer = YES) |
6 | Correct | 2 ms | 296 KB | OK (n = 3, answer = YES) |
7 | Correct | 1 ms | 376 KB | OK (n = 3, answer = YES) |
8 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
9 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
10 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
11 | Correct | 2 ms | 380 KB | OK (n = 3, answer = YES) |
12 | Correct | 2 ms | 376 KB | OK (n = 3, answer = YES) |
13 | Correct | 2 ms | 256 KB | OK (n = 3, answer = NO) |
14 | Incorrect | 2 ms | 256 KB | Contestant can not find answer, jury can |
15 | Halted | 0 ms | 0 KB | - |