Submission #172470

# Submission time Handle Problem Language Result Execution time Memory
172470 2020-01-01T15:47:15 Z gs18103 Detecting Molecules (IOI16_molecules) C++14
9 / 100
3 ms 380 KB
#include "molecules.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MAX = 505050;
const int INF = INT_MAX >> 1;
const ll LINF = LLONG_MAX >> 1;
const ll mod = 1e9+9;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector <int> ans;
    vector <pii> W;
    for(int i = 0; i < w.size(); i++) W.eb(w[i], i);
    sort(all(W));
    reverse(all(W));
    int sum = 0;
    for(int i = 0; i < W.size(); i++) {
        if(sum < l && sum + W[i].fi <= u) sum += W[i].fi, ans.eb(W[i].se);
        if(sum >= l && sum <= u) break;
    }
    sort(all(ans));
    if(sum >= l && sum <= u) return ans;
    else return vector <int> {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < w.size(); i++) W.eb(w[i], i);
                    ~~^~~~~~~~~~
molecules.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < W.size(); i++) {
                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 252 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 256 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 1 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 3 ms 376 KB OK (n = 3, answer = NO)
14 Correct 1 ms 296 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 256 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 252 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 256 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 1 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 3 ms 376 KB OK (n = 3, answer = NO)
14 Correct 1 ms 296 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 256 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 252 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 256 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 1 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 3 ms 376 KB OK (n = 3, answer = NO)
14 Correct 1 ms 296 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 256 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 252 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 256 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 1 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 3 ms 376 KB OK (n = 3, answer = NO)
14 Correct 1 ms 296 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 256 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 252 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 256 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 1 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 3 ms 376 KB OK (n = 3, answer = NO)
14 Correct 1 ms 296 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 256 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -