답안 #1069952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069952 2024-08-22T10:32:56 Z TheQuantiX Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 512 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll n, m, q, k, x, y, a, b, c;

vector<int> find_subset(int l, int u, vector<int> w) {
    n = w.size();
    vector<int> ans;
    vector< pair<ll, ll> > v(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (w[i] >= l && w[i] <= u) {
            ans.push_back(i);
            return ans;
        }
        v.push_back({w[i], i});
        sum += w[i];
    }
    sort(v.begin(), v.end());
    if (sum >= l && sum <= u) {
        for (int i = 0; i < n; i++) {
            ans.push_back(i);
        }
        return ans;
    }
    if (sum < l) {
        return ans;
    }
    if (v[0].first > u) {
        return ans;
    }
    set< pair<ll, ll> > st1, st2;
    for (int i = 0; i < w.size(); i++) {
        st1.insert({w[i], i});
    }
    ll num = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (num += v[i].first <= u) {
            num += v[i].first;
            st2.insert(v[i]);
            st1.erase(v[i]);
        }
    }
    // for (int i = 0; i < n; i++) {
    //     if (num += v[i].first <= u) {
    //         num += v[i].first;
    //         st2.insert(v[i]);
    //         st1.erase(v[i]);
    //     }
    // }
    // if (l <= num && num <= u) {
    //     for (auto i : st2) {
    //         ans.push_back(i.second);
    //     }
    //     return ans;
    // }
    // ll mx = num;
    // while (num < l && num >= mx) {
    //     if ((*st1.rbegin()).first >= (*st2.begin()).first) {
    //         st2.insert(*st1.lower_bound());
    //     }
    //     else {
            
    //     }

    // }
    if (l <= num && num <= u) {
        for (auto i : st2) {
            ans.push_back(i.second);
        }
        return ans;
    }
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 1 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Incorrect 1 ms 344 KB Contestant can not find answer, jury can
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 1 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Incorrect 1 ms 344 KB Contestant can not find answer, jury can
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 1 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Incorrect 1 ms 344 KB Contestant can not find answer, jury can
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 1 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Incorrect 1 ms 344 KB Contestant can not find answer, jury can
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 1 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Incorrect 1 ms 344 KB Contestant can not find answer, jury can
9 Halted 0 ms 0 KB -