Submission #225619

# Submission time Handle Problem Language Result Execution time Memory
225619 2020-04-21T00:06:56 Z fishy15 Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 384 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include "molecules.h"

#define ll long long
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 1000000

using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = (int)(w.size());
    vector<pair<int, int>> pos;
    for (int i = 0; i < n; i++) {
        pos.push_back({w[i], i});
    }

    sort(pos.begin(), pos.end());
    ll cur = 0;
    int back = 0;
    int p = 0;

    vector<int> ans;
    while (p < n) {
        cout << p << '\n';
        while (p < n && cur < l) {
            cur += pos[p++].first;
        }

        while (back < p && cur > u) {
            cur -= pos[back++].first;
        }

        if (l <= cur && cur <= u) {
            for (int i = back; i < p; i++) {
                ans.push_back(pos[i].second);
            }
            return ans;
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Secret is incorrect!
2 Halted 0 ms 0 KB -