| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 409011 | Gurban | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
using ll = long long;
const int maxn=2e5+5;
ll p[maxn];
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int>ans;
if(l > u) return ans;
ll cnt = 0;
for(int i = 0;i < (int)w.size();i++){
if(w[i] >= l and w[i] <= u){
ans.push_back(i);
return ans;
}
if(w[i] < l) cnt += w[i];
}
if(cnt < l) return ans;
vector<pair<int,int>>v;
for(int i = 0;i < (int)w.size();i++) v.push_back({w[i],i});
sort(v.begin(),v.end());
// for(auto i : v){
// cout<<i.first<<' '<<i.second<<'\n';
// }
int lft = 0,rgt = (int)w.size()-1;
ll lft_s = 0,rgt_s = 0;
while(lft < (int)w.size() and rgt >= 0){
lft_s += v[lft++].first;
rgt_s += v[rgt--].first;
if(lft_s >= l and lft_s <= u){
for(int i = 0;i < lft;i++) ans.push_back(v[i].second);
return ans;
}
if(rgt_s >= l and rgt_s <= u){
for(int i = rgt+1;i < (int)w.size();i++) ans.push_back(v[i].second);
return ans;
}
if(lft_s > u) return ans;
if(rgt_s < l) continue;
if(lft_s < l and rgt_s > u){
for(int i = 0;i < lft;i++){
if(lft_s < l){
lft_s += v[rgt].first-v[i].first;
ans.push_back(v[rgt].second);
}
else ans.push_back(v[i].second);
rgt++;
}
return ans;
}
}
}
// int main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
// int n,l,r; cin >> n >> l >> r;
// vector<int>w(n);
// for(int i = 0;i < n;i++) cin >> w[i];
// vector<int> ans = find_subset(l,r,w);
// for(auto i : ans) cout<<i<<' ';
// }
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
