답안 #1098051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1098051 2024-10-09T01:36:02 Z dzhoz0 Detecting Molecules (IOI16_molecules) C++17
0 / 100
0 ms 348 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;


std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n = (int)w.size();
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        a[i].first = w[i];
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    vector<long long> ps(n);
    ps[0] = a[0].first;
    for (int i = 1; i < n; i++) {
        ps[i] = ps[i - 1] + a[i].first;
    }
    if(*lower_bound(ps.begin(), ps.end(), l) <= u) {
        vector<int> res;
        for (int i = 0; i < n; i++)
        {
            res.push_back(i);
            if(ps[i] >= l && ps[i] <= u)
                break;
            return res;
        }
    }

    for (int i = 0; i < n; i++) {
        auto it = lower_bound(ps.begin(), ps.end(), ps[i] + l);
        if(it == ps.end())
            continue;
        if(*it - ps[i] <= u) {
            int id = it - ps.begin();
            vector<int> res;
            for (int j = i + 1; j <= id; j++)
            {
                res.push_back(j);
            }
            return res;
        }
    }
    return std::vector<int>(0);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB sum of weights should be in [10..12] but it is 9
2 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 Incorrect 0 ms 348 KB sum of weights should be in [290..300] but it is 50
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -