| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 163879 | YazanZk | Cover (COCI18_cover) | C++14 | 8 ms | 760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll ;
using namespace std;
vector < pair < ll , ll > > vec;
ll memo[5005];
const ll inf = 1e18 ;
ll solve(int i){
if(i == vec.size()) return 0 ;
ll &ret = memo[i];
if(ret != -1) return ret ;
ll x = vec[i].first ;
ret = inf ;
for(int j = i ; j < (int)vec.size() ; j++){
ret = min(ret, 4 * x * vec[j].second + solve(j + 1));
}
return ret ;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n ;
cin >> n ;
vector < pair < ll, ll > > ve;
for(int i = 0 ; i < n ; i++) {
ll x,y ;
cin >> x >> y ;
x = abs(x);
y = abs(y);
ve.push_back({x, y});
}
sort(ve.rbegin(), ve.rend());
vector < bool > vis(n , 0);
for(int i = 0 ; i < n ; i++){
for(int j = i + 1 ; j < n ; j++){
if(vis[j]) continue;
if(ve[i].second < ve[j].second) break ;
else vis[j] = 1;
}
}
for(int i = 0 ; i < n ; i++){
if(!vis[i]) vec.push_back(ve[i]);
}
memset(memo , -1 , sizeof memo);
cout << solve(0) << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
