제출 #1135086

#제출 시각아이디문제언어결과실행 시간메모리
1135086AvianshSafety (NOI18_safety)C++20
13 / 100
2095 ms1888 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,h; cin >> n >> h; int arr[n]; int mxval = 0; for(int &i : arr){ cin >> i; mxval=max(mxval,i); } multiset<int>pts; long long m = 1; long long c = -arr[0]; pts.insert(arr[0]); pts.insert(arr[0]); for(int i = 1;i<n;i++){ multiset<int>temp; int cn = 0; for(int j : pts){ if(cn>=i){ temp.insert(j+h); } else{ temp.insert(j-h); } cn++; } temp.insert(arr[i]); temp.insert(arr[i]); //point addition: c-=arr[i]; //expansion: c-=h*m; m++; pts=temp; } multiset<int>::iterator it = pts.end(); int cn = 0; while(cn<n){ it--; c+=*it; m--; cn++; } cout << m*(*it)+c; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...