답안 #276684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276684 2020-08-20T15:10:43 Z ajpiano Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 384 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(; 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);
        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;
//}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 368 KB OK (n = 12, answer = YES)
2 Correct 1 ms 256 KB OK (n = 12, answer = YES)
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -