# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223732 | 2020-04-16T09:03:20 Z | bharat2002 | Detecting Molecules (IOI16_molecules) | C++14 | 5 ms | 384 KB |
#include "molecules.h" #include<bits/stdc++.h> using namespace std; const int N=2e5 + 100; const int mod=1e9 + 7; #define pii pair<int, int> #define mp make_pair #define f first #define s second int n;vector< pii > vals; bool sf(pii a, pii b);int pref[N]; vector<int> ans;int L, U; void check(int num) { if(pref[num-1]<=U) { for(int i=0;i<num;i++) ans.push_back(vals[i].s);return; } for(int i=num;i<n;i++) { if(pref[i]-pref[i-num]>=L&&pref[i]-pref[i-num]<=U) { for(int j=i-num+1;j<=i;j++) ans.push_back(vals[j].s);return; } } } vector<int> find_subset(int l, int u, vector<int> w) { vals.clear();L=l;U=u; n=w.size(); for(int i=0;i<w.size();i++) { vals.push_back(mp(w[i], i)); } sort(vals.begin(), vals.end(), sf); int mval=vals.back().f; for(auto &i:vals) i.f-=mval; pref[0]=0;; for(int i=0;i<vals.size();i++) { pref[i]=vals[i].f; if(i>0) pref[i]+=pref[i-1]; } if(mval>u) return ans; for(int i=1;i<=n;i++) { if(i==n) { if(pref[n-1]>=l&&pref[n-1]<=u) { for(int i=0;i<n;i++) ans.push_back(vals[i].s); } break; } int maxsum=pref[i-1], minsum=pref[n-1] - pref[n-i-1]; if(minsum<=l&&maxsum>=l) { check(i); if(!ans.empty()) break; } } return ans; } bool sf(pii a, pii b) { return a.f>b.f; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | OK (n = 1, answer = NO) |
2 | Correct | 4 ms | 256 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 5 ms | 384 KB | Contestant can not find answer, jury can |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Contestant can not find answer, jury can |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | OK (n = 1, answer = NO) |
2 | Correct | 4 ms | 256 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 5 ms | 384 KB | Contestant can not find answer, jury can |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | OK (n = 1, answer = NO) |
2 | Correct | 4 ms | 256 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 5 ms | 384 KB | Contestant can not find answer, jury can |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | OK (n = 1, answer = NO) |
2 | Correct | 4 ms | 256 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 5 ms | 384 KB | Contestant can not find answer, jury can |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | OK (n = 1, answer = NO) |
2 | Correct | 4 ms | 256 KB | OK (n = 1, answer = NO) |
3 | Incorrect | 5 ms | 384 KB | Contestant can not find answer, jury can |
4 | Halted | 0 ms | 0 KB | - |