# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27204 | 2017-07-10T13:12:12 Z | TAMREF | Min-cost GCD (GA9_mcg) | C++11 | 1000 ms | 32768 KB |
#include <bits/stdc++.h> #define va first #define vb second #define mp make_pair using namespace std; typedef long long ll; typedef pair<ll,ll> pll; map<pll,int> m; ll s,t; int rec(pll p){ if(!p.va||!p.vb) return 0; if(m[p]) return m[p]; ll x=p.va,y=p.vb; return m[p]=min(rec(mp(y,x%y))+s,rec(x>=y?mp(x-y,y):mp(x,y-x))+t); } int main(){ pll x; int T; for(scanf("%d",&T);T--;){ m.clear(); scanf("%lld%lld%lld%lld",&x.va,&x.vb,&s,&t); printf("%d\n",rec(x)); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2024 KB | Output is correct |
2 | Correct | 0 ms | 2024 KB | Output is correct |
3 | Correct | 0 ms | 2024 KB | Output is correct |
4 | Correct | 0 ms | 2024 KB | Output is correct |
5 | Correct | 0 ms | 2024 KB | Output is correct |
6 | Correct | 0 ms | 2024 KB | Output is correct |
7 | Correct | 0 ms | 2024 KB | Output is correct |
8 | Correct | 0 ms | 2024 KB | Output is correct |
9 | Correct | 0 ms | 2024 KB | Output is correct |
10 | Correct | 0 ms | 2024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 2384 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 106 ms | 4072 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Memory limit exceeded | 86 ms | 32768 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |