Submission #145648

# Submission time Handle Problem Language Result Execution time Memory
145648 2019-08-20T16:20:27 Z karma Detecting Molecules (IOI16_molecules) C++11
0 / 100
3 ms 376 KB
#include<bits/stdc++.h>
//#include "molecules.h"
#define mp   make_pair
#define fi   first
#define se   second

using namespace std;

typedef pair<int, int> pii;

vector<int> find_subset(int l, int u, vector<int> w)
{
    vector<pii> _w;
    vector<bool> used;
    vector<int> ans; ans.clear();
    int n, pivot = -1, s = 0;
    n = w.size(); _w.resize(n); used.resize(n);
    for(int i = 0; i < n; ++i) {
        if(w[i] >= l && w[i] <= u) {
            ans.push_back(i); return ans;
        }
        _w[i] = mp(w[i], i);
    }
    sort(_w.begin(), _w.end());
    for(int i = 0; i < n; ++i) {
        if(s + _w[i].fi <= l) s += _w[i].fi, used[_w[i].se] = 1, pivot = i;
        else break;
    }
    if(s >= l && s <= u) {
        for(int i = 0; i < n; ++i) if(used[i]) ans.push_back(i);
        return ans;
    }
    for(int i = pivot + 1; i < n; ++i) {
        if(_w[i].fi > u) break;
        int upper = _w[i].fi - l + s, lower = _w[i].fi - u + s;
        int pos = lower_bound(_w.begin(), _w.begin() + pivot, mp(lower, -1)) - _w.begin();
        if(_w[pos].fi <= upper && _w[pos].fi >= lower) {
            s -= _w[pos].fi; s += _w[i].fi;
            used[_w[pos].se] = 0, used[_w[i].se] = 1; break;
        }
    }
    if(s >= l && s <= u) {
        for(int i = 0; i < n; ++i) if(used[i]) ans.push_back(i);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 256 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 3 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 2 ms 256 KB OK (n = 3, answer = YES)
12 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 256 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 3 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 2 ms 256 KB OK (n = 3, answer = YES)
12 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 256 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 3 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 2 ms 256 KB OK (n = 3, answer = YES)
12 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 256 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 3 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 2 ms 256 KB OK (n = 3, answer = YES)
12 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 256 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 3 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 2 ms 256 KB OK (n = 3, answer = YES)
12 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
13 Halted 0 ms 0 KB -