# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
778109 | vjudge1 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 8e5+37;
#include <cstdio>
#include <vector>
#include <cassert>
#include "molecules.h"
void f(){
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
vector<int> find_subset(int l, int u, vector<int> w) {
int n= w.size();
vector<array<int, 2>> a(n);
for(int i=0; i<n; i++){
a[i]={w[i], i};
}
sort(a.begin(), a.end());
if(a[0][0]>u)
return vector<int>(0);
int sum=0, k=-1;
for(int i=0; i<n&&k==-1; i++){
if(sum+a[i][0]>l){
k=i;
}
else{
sum+=a[i][0];
}
}
if(k==-1) return std::vector<int>(0);
if(k==0){
vector<int> ans(1);
ans[0]=a[0][1];
return ans;
}
sum-=a[0][0];
sum+=a[n-1][0];
if(sum<l||sum>u) return std::vector<int>(0);
vector<int> ans;
for(int i=1; i<k; i++){
ans.push_back(a[i][1]);
}
ans.push_back(a[n-1][1]);
sort(ans.begin(), ans.end());
return ans;
}/*
signed main() {
f();
int n, l, u;
assert(3 == scanf("%d %d %d", &n, &l, &u));
std::vector<int> w(n);
for (int i = 0; i < n; i++)
assert(1 == scanf("%d", &w[i]));
std::vector<int> result = find_subset(l, u, w);
// BEGIN SECRET
puts("14e047d7a2907b9034950b074822b302");
// END SECRET
printf("%d\n", (int)result.size());
for (int i = 0; i < (int)result.size(); i++)
printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
}*/
/*
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
f();
int n; cin >> n;
int u, v; cin >> u>>v;
vector<int> a(n);
for(int i=0; i<n; i++) cin >> a[i];
auto x= find_subset(u, v, a);
cout<<n<<"\n";
for(auto i: x) cout<<i<<" ";
cout<<"\n";
}*/
컴파일 시 표준 에러 (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... |