답안 #1092961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092961 2024-09-25T14:14:31 Z Phuoc Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define el '\n'
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define MASK(i) (1LL << (i))
#define fi first
#define se second

#include <molecules.h>


template <class T1, class T2>
    bool minimize(T1 &a, T2 b) {
        if(a > b){a = b; return true;} return false;
    }

template <class T1, class T2>
    bool maximize(T1 &a, T2 b) {
        if(a < b) {a = b; return true;} return false;
    }

const ll MOD = (ll)1e9 + 7;

template <class T1, class T2>
    void add(T1 &a, T2 b) {
        a += b;
        if(a >= MOD) a -= MOD;
    }

const ll INF = (ll)1e18 + 10LL;
const int oo = (int)1e9 + 10;
const int MAX = 555;
const int MAX_EDGE = (int)2e5 + 10;
const int LOG = 20;


vector <int> find_subset(int l, int r, vector <int> a) {
    ll cur = 0;
    int j = 0;
    vector <pair<ll, int> > ord;
    for (int i = 0; i < a.size(); i++) {
        ord.push_back(make_pair(a[i], i));
    }
    sort(ord.begin(), ord.end());
    for(int i = 0; i < a.size(); i++) {
        cur += ord[i].fi;
        while(cur > r) {
            cur -= ord[j++].fi;
        }
        if(cur >= l) {
            vector <int> ans;
            for(int k = j; k <= i; k++) {
                ans.push_back(ord[k].se);
            }
            return ans;
        }
    }
}

// int main (void) {
//     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//     #define task "test"
//     // freopen(task".inp", "r", stdin);
//     // freopen(task".out", "w", stdout);
//     int ntest = 1;
//     // cin >> ntest;
//     srand(time(0));
//     // while(ntest--) {
//     //     init();
//     //     solve();
//     // }
//     // vector <int> ans = find_subset(15, 17, {6, 8, 8, 7});
//     int l = 15, r = 17;
//     vector <int> a;
//     a.push_back(6); a.push_back(8); a.push_back(8); a.push_back(7);
//     vector <int> ans = find_subset(l, r, a);
//     for(int x:ans) cout << x << ' ';
//     return 0;
// }

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
molecules.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < a.size(); i++) {
      |                    ~~^~~~~~~~~~
molecules.cpp:45:29: warning: control reaches end of non-void function [-Wreturn-type]
   45 |     vector <pair<ll, int> > ord;
      |                             ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Runtime error 0 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -