Submission #276695

# Submission time Handle Problem Language Result Execution time Memory
276695 2020-08-20T15:17:59 Z ajpiano Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 640 KB
#include <bits/stdc++.h>
#include <molecules.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))
#define all(x) x.begin(), x.end()

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

vi find_subset(int d, int u, vi w){
    int n = w.size();
    vector<pair<ll,int>> w2(n);
    FOR(i,n) w2[i].f = w[i];
    FOR(i,n) w2[i].s = i+1;
    sort(all(w2));
    int l = 0, r = 0;
    ll total = 0;
    for(; l < n; l++){
        if(r < l){
            total = 0;
            r = l;
        }else if(l != 0) total -= w2[l-1].f;
        for(; (r<n && total+w2[r].f <= u); r++) total += w2[r].f;
        if(total >= d) break;
    }
    if(l == r){
        vi ans;
        return ans;
    }else{
        vi ans(r-l);
        assert(r <= n);
        assert(l < n);
        FOR(i,r-l) ans[i] = w2[l+i].s;
        return ans;
    }
}

//void testf(){
//    int n,l,u;
//    cin >> n >> l >> u;
//    int w[n]; FOR(i,n) cin >> w[i];
//    int ans[n];
//    int m = find_subset(l,u,w,n,ans);
//    cout << m << "\n";
//    FOR(i,m) cout << ans[i] << " ";
//    cout << "\n";
//}
//
//int main()
//{
//    ios_base::sync_with_stdio(0); cin.tie(0);
////    testf();
//    return 0;
//}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 3 ms 640 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 12, answer = YES)
2 Correct 0 ms 256 KB OK (n = 12, answer = YES)
3 Correct 1 ms 256 KB OK (n = 12, answer = NO)
4 Correct 0 ms 256 KB OK (n = 12, answer = NO)
5 Incorrect 1 ms 256 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 256 KB OK (n = 1, answer = NO)
2 Runtime error 3 ms 640 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 3 ms 640 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 3 ms 640 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 3 ms 640 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -