Submission #307752

# Submission time Handle Problem Language Result Execution time Memory
307752 2020-09-29T09:23:39 Z lohacho Detecting Molecules (IOI16_molecules) C++14
9 / 100
1 ms 384 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

using LL = long long;
const LL INF = (LL)1e9 + 7;
const LL NS = (LL)1e5 + 4;
LL lsum[NS], rsum[NS];
vector <int> ans;
vector <pair<LL, LL>>srt;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    for(LL i = 0; i < (LL)w.size(); ++i){
        srt.push_back(make_pair(w[i], i));
    }
    LL N = (LL)srt.size();
    sort(srt.begin(), srt.end());
    for(LL i = 0; i < N; ++i){
        lsum[i] = srt[i].first;
        if(i){
            lsum[i] += lsum[i - 1];
        }
    }
    for(LL i = N - 1; i >= 0; --i){
        rsum[i] = srt[i].first + rsum[i + 1];
    }
    LL choose = -1;
    for(LL i = 0; i < N; ++i){
        LL low = lsum[i], high = rsum[N - i - 1];
        if(low > high){
            swap(low, high);
        }
        if(!(low > u || high < l)){
            choose = i + 1;
        }
    }
    if(choose == -1){
        vector < int > emp;
        return emp;
    }
    LL sum = 0;
    ans.resize(choose);
    for(LL i = N - 1; i >= N - choose; --i){
        sum += srt[i].first;
        ans[choose - (N - i)] = i;
    }
    int nxt = 0;
    for(int i = 0; i < N; ++i){
        if(i >= nxt || nxt >= choose){
            break;
        }
        if(sum - srt[ans[nxt]].first + srt[i].first < l){
            continue;
        }
        sum += srt[i].first - srt[ans[nxt]].first;
        ans[nxt] = i;
        ++nxt;
    }
    for(LL i = 0; i < choose; ++i){
        ans[i] = srt[ans[i]].second;
    }
    sort(ans.begin(), ans.end());
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 384 KB OK (n = 1, answer = NO)
3 Correct 1 ms 384 KB OK (n = 1, answer = YES)
4 Correct 0 ms 384 KB OK (n = 2, answer = YES)
5 Correct 1 ms 256 KB OK (n = 2, answer = YES)
6 Correct 0 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 384 KB OK (n = 3, answer = YES)
8 Correct 1 ms 384 KB OK (n = 3, answer = YES)
9 Correct 1 ms 256 KB OK (n = 3, answer = YES)
10 Correct 1 ms 384 KB OK (n = 3, answer = YES)
11 Correct 1 ms 384 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Correct 1 ms 384 KB OK (n = 3, answer = NO)
14 Correct 1 ms 256 KB OK (n = 3, answer = YES)
15 Correct 1 ms 256 KB OK (n = 3, answer = YES)
16 Correct 1 ms 384 KB OK (n = 3, answer = NO)
17 Correct 1 ms 384 KB OK (n = 3, answer = NO)
18 Correct 1 ms 384 KB OK (n = 100, answer = NO)
19 Correct 1 ms 384 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB sum of weights should be in [302..304] but it is 306
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 384 KB OK (n = 1, answer = NO)
3 Correct 1 ms 384 KB OK (n = 1, answer = YES)
4 Correct 0 ms 384 KB OK (n = 2, answer = YES)
5 Correct 1 ms 256 KB OK (n = 2, answer = YES)
6 Correct 0 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 384 KB OK (n = 3, answer = YES)
8 Correct 1 ms 384 KB OK (n = 3, answer = YES)
9 Correct 1 ms 256 KB OK (n = 3, answer = YES)
10 Correct 1 ms 384 KB OK (n = 3, answer = YES)
11 Correct 1 ms 384 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Correct 1 ms 384 KB OK (n = 3, answer = NO)
14 Correct 1 ms 256 KB OK (n = 3, answer = YES)
15 Correct 1 ms 256 KB OK (n = 3, answer = YES)
16 Correct 1 ms 384 KB OK (n = 3, answer = NO)
17 Correct 1 ms 384 KB OK (n = 3, answer = NO)
18 Correct 1 ms 384 KB OK (n = 100, answer = NO)
19 Correct 1 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 1 ms 384 KB sum of weights should be in [302..304] but it is 306
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 384 KB OK (n = 1, answer = NO)
3 Correct 1 ms 384 KB OK (n = 1, answer = YES)
4 Correct 0 ms 384 KB OK (n = 2, answer = YES)
5 Correct 1 ms 256 KB OK (n = 2, answer = YES)
6 Correct 0 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 384 KB OK (n = 3, answer = YES)
8 Correct 1 ms 384 KB OK (n = 3, answer = YES)
9 Correct 1 ms 256 KB OK (n = 3, answer = YES)
10 Correct 1 ms 384 KB OK (n = 3, answer = YES)
11 Correct 1 ms 384 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Correct 1 ms 384 KB OK (n = 3, answer = NO)
14 Correct 1 ms 256 KB OK (n = 3, answer = YES)
15 Correct 1 ms 256 KB OK (n = 3, answer = YES)
16 Correct 1 ms 384 KB OK (n = 3, answer = NO)
17 Correct 1 ms 384 KB OK (n = 3, answer = NO)
18 Correct 1 ms 384 KB OK (n = 100, answer = NO)
19 Correct 1 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 1 ms 384 KB sum of weights should be in [302..304] but it is 306
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 384 KB OK (n = 1, answer = NO)
3 Correct 1 ms 384 KB OK (n = 1, answer = YES)
4 Correct 0 ms 384 KB OK (n = 2, answer = YES)
5 Correct 1 ms 256 KB OK (n = 2, answer = YES)
6 Correct 0 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 384 KB OK (n = 3, answer = YES)
8 Correct 1 ms 384 KB OK (n = 3, answer = YES)
9 Correct 1 ms 256 KB OK (n = 3, answer = YES)
10 Correct 1 ms 384 KB OK (n = 3, answer = YES)
11 Correct 1 ms 384 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Correct 1 ms 384 KB OK (n = 3, answer = NO)
14 Correct 1 ms 256 KB OK (n = 3, answer = YES)
15 Correct 1 ms 256 KB OK (n = 3, answer = YES)
16 Correct 1 ms 384 KB OK (n = 3, answer = NO)
17 Correct 1 ms 384 KB OK (n = 3, answer = NO)
18 Correct 1 ms 384 KB OK (n = 100, answer = NO)
19 Correct 1 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 1 ms 384 KB sum of weights should be in [302..304] but it is 306
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 384 KB OK (n = 1, answer = NO)
3 Correct 1 ms 384 KB OK (n = 1, answer = YES)
4 Correct 0 ms 384 KB OK (n = 2, answer = YES)
5 Correct 1 ms 256 KB OK (n = 2, answer = YES)
6 Correct 0 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 384 KB OK (n = 3, answer = YES)
8 Correct 1 ms 384 KB OK (n = 3, answer = YES)
9 Correct 1 ms 256 KB OK (n = 3, answer = YES)
10 Correct 1 ms 384 KB OK (n = 3, answer = YES)
11 Correct 1 ms 384 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Correct 1 ms 384 KB OK (n = 3, answer = NO)
14 Correct 1 ms 256 KB OK (n = 3, answer = YES)
15 Correct 1 ms 256 KB OK (n = 3, answer = YES)
16 Correct 1 ms 384 KB OK (n = 3, answer = NO)
17 Correct 1 ms 384 KB OK (n = 3, answer = NO)
18 Correct 1 ms 384 KB OK (n = 100, answer = NO)
19 Correct 1 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 1 ms 384 KB sum of weights should be in [302..304] but it is 306
21 Halted 0 ms 0 KB -