# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962708 | 2024-04-14T07:20:03 Z | hirayuu_oj | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 348 KB |
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) #define all(x) x.begin(),x.end() using ll=long long; void out(int x){ cerr<<x; } void out(ll x){ cerr<<x; } template<typename F,typename S> void out(pair<F,S> x){ cerr<<"("; out(x.first); cerr<<", "; out(x.second); cerr<<")"; } template<typename S> void out(S x){ cerr<<"["; for(auto i:x){ out(i); cerr<<", "; } cerr<<"]"; } template<typename H> void DBG(H x){ cerr<<"DBG:"; out(x); cerr<<"\n"; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=w.size(); vector<ll> cum(w.size()+1,0); vector<pair<ll,ll>> wi(w.size()); rep(i,w.size()){ wi[i]={w[i],i}; } sort(all(wi)); rep(i,n){ cum[i+1]=cum[i]+wi[i].first; } rep(i,n+1){ if(cum[i]>u)continue; if(cum[n]-cum[n-i]<l)continue; rep(j,i+1){ if(l<=cum[j]+cum[n]-cum[n-(i-j)]&&cum[j]+cum[n]-cum[n-(i-j)]<=u){ vector<int> ans(0); ll wei=0; rep(k,j){ ans.push_back(wi[k].second+1); wei+=wi[k].first; } rep(k,i-j){ ans.push_back(wi[n-k-1].second+1); wei+=wi[k].second; } assert(l<=wei&&wei<=u); return ans; } } } return std::vector<int>(0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
2 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
3 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
2 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
3 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
2 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
3 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
2 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
3 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
2 | Correct | 0 ms | 348 KB | OK (n = 1, answer = NO) |
3 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |