Submission #289640

# Submission time Handle Problem Language Result Execution time Memory
289640 2020-09-02T20:50:24 Z peti1234 Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 256 KB
#include <bits/stdc++.h>

using namespace std;
long long sum, n, kezd=-1, veg;
vector<pair<long long, int> >sz;
vector<int> ans;
void add(int a, int b) {
    sum+=b*sz[a].first;
}
vector<int> find_subset(int a, int b, vector<int> w) {
    n=w.size(), veg=n;
    for (int i=0; i<n; i++) {
        sz.push_back({w[i], i});
    }
    sort(sz.rbegin(), sz.rend());
    while(kezd+1<n && sum<a) {
        kezd++;
        add(kezd, 1);
    }
    if (kezd<=sum && sum<=veg) {
        for (int i=0; i<=kezd; i++) ans.push_back(sz[i].second);
        return ans;
    }
    while(kezd>=0 && sum>b) {
        add(kezd, -1), kezd--;
        veg--, add(veg, 1);
        if (sum<=b) {
            for (int i=0; i<=kezd; i++) ans.push_back(sz[i].second);
            for (int i=veg; i<n; i++) ans.push_back(sz[i].second);
            return ans;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 12, answer = YES)
2 Correct 0 ms 256 KB OK (n = 12, answer = YES)
3 Correct 0 ms 256 KB OK (n = 12, answer = NO)
4 Correct 0 ms 256 KB OK (n = 12, answer = NO)
5 Correct 0 ms 256 KB OK (n = 12, answer = YES)
6 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -