Submission #1071679

# Submission time Handle Problem Language Result Execution time Memory
1071679 2024-08-23T09:56:45 Z kukuk Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 432 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int ukr = 2e5+10;
vector<pair<int,int>> ar;
vector<int> ans;
vector<int> find_subset(int l, int u, vector<int> w) {
    int n;
    n = w.size();
    for(int i = 0; i < n; i++){
        ar.push_back({w[i], i+1});
    }
    sort(ar.begin(), ar.end());
    ll tot = 0;
    int ki = 0, ka = 0;
    while(ki < n){
        while(ka < n && tot+ar[ka].first <= u){
            tot += ar[ka].first;
            ka++;
        }
        //cout << ki << " " << ka << " " << tot << " " << ar[ki].first << "\n"; 
        if(tot >= l && tot <= u){
            for(int i = ki; i < ka; i++){
                ans.push_back(ar[i].second);
            }
            return ans;
        }
        tot -= ar[ki].first;
        ki++;
        if(tot >= l && tot <= u){
            for(int i = ki; i < ka; i++){
                ans.push_back(ar[i].second);
            }
            return ans;
        }
    }
    return ans;
}
/* int main() {
    int n, l, u;
    assert(3 == scanf("%d %d %d", &n, &l, &u));
    std::vector<int> w(n);
    for (int i = 0; i < n; i++)
        assert(1 == scanf("%d", &w[i]));
    std::vector<int> result = find_subset(l, u, w);
    
    
    printf("%d\n", (int)result.size());
    for (int i = 0; i < (int)result.size(); i++)
        printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
} */
# Verdict Execution time Memory 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 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 12, answer = YES)
2 Correct 0 ms 432 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 301
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -