# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
751359 | coding_snorlax | Cyberland (APIO23_cyberland) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Main problem : the final place can't choose as a divide 2 cycle. So sometime should early made the divide 2 operations.
#include<bits/stdc++.h>
//#include "cyberland.h"
using namespace std;
using ll = long long int;
double dis[100002];
double solve(int N,int M,int K,int H, vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
for(int i=0;i<N;i++) dis[i]=0;
long long int Max_0=-1,Max_2=-1;
double answer = 0;
for(int i=0;i<H;i++){
if(arr[i+1]==0){ Max_0 = i+1; answer=0;}
else if(arr[i+1]==1) answer+=c[i];
else {Max_2 = i+1; answer += c[i];}
dis[i+1] = answer;
}
if(Max_0<Max_2){
long long int check = min(c[Max_2-1],c[Max_2]);
answer = dis[Max_2]/2;
cout << answer << "\n";
K--;
for(int i=0;i<K;i++){
double comp = (answer + 2.0 * check) / 2.0;
if(comp < answer) answer = comp;
cout << answer << "\n";
}
for(int i = Max_2 ; i<H;i++){
answer += c[i];
}
}
cout << Max_2 << "\n";
return answer;
}
int main(){
int T;
cin>>T;
for(int s=0;s<T;s++){
int N,M,K,H;
cin>>N>>M>>K>>H;
vector<int> x,y,c,arr;
for(int i=0;i<N;i++){
int tmp;
cin>>tmp;
arr.push_back(tmp);
}
for(int i=0;i<M;i++){
int tmp1,tmp2,tmp3;
cin>>tmp1>>tmp2>>tmp3;
x.push_back(tmp1);
y.push_back(tmp2);
c.push_back(tmp3);
}
cout << solve(N,M,K,H,x,y,c,arr) << "\n";
}
}