답안 #1083944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083944 2024-09-04T15:22:55 Z pravcoder Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 604 KB
#include "molecules.h"
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> v2i;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

#define pb push_back
#define mp make_pair
#define rept(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vpi ms;
    int n = w.size();
    rep(i, n) ms.pb({ w[i], i });
    sort(ms.begin(), ms.end());
    ll s = 0;
    queue<pi> q;
    bool found = true;
    for (int i = 0; i < n && (s < l || s > u);) {
        if (s < l) {
            q.push(ms[i]);
            s += ms[i].first;
            i++;
        }
        else {
            s -= q.front().first;
            q.pop();
        }
        if (i >= n) found = false;
    }

    vi res;
    res.reserve(n);
    if (!found) return res;
    while (!q.empty()) {
        res.pb(q.front().second);
        q.pop();
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Correct 0 ms 348 KB OK (n = 12, answer = NO)
4 Correct 0 ms 348 KB OK (n = 12, answer = NO)
5 Correct 0 ms 344 KB OK (n = 12, answer = YES)
6 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -