제출 #1117561

#제출 시각아이디문제언어결과실행 시간메모리
1117561JuanJL나일강 (IOI24_nile)C++17
67 / 100
2056 ms21180 KiB
#include <bits/stdc++.h> using namespace std; #define fst first #define snd second #define SZ(x) (int)x.size() #define ALL(x) x.begin(),x.end() #define pb push_back #define forn(i,a,b) for(int i = a; i < b; i++) #define mset(a,v) memset(a,v,sizeof(a)) #define INF 100000000000000000 typedef long long ll; const int MAXN = 1000000+5; struct Objeto{ ll peso; ll costoA; ll costoB; }; bool operator<(const Objeto &a, const Objeto &b){ if(a.peso<b.peso) return true; if(a.peso>b.peso) return false; if(a.costoA-a.costoB < b.costoA-b.costoB) return true; return false; } vector<Objeto> o; ll e; ll dp[MAXN]; ll f(ll x){ ll &res = dp[x]; if(res!=-1) return res; if(x==SZ(o)) return 0; res = o[x].costoA+f(x+1); ll aux=0; if(x+1<SZ(o)&&abs(o[x].peso-o[x+1].peso)<=e) res=min(res,o[x].costoB+o[x+1].costoB+f(x+2)); if(x+2<SZ(o) && abs(o[x].peso-o[x+2].peso)<=e ) res=min(res,o[x].costoB+o[x+2].costoB+o[x+1].costoA+f(x+3)); return res; } vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E){ vector<ll> r; forn(i,0,SZ(W)){ Objeto aux; o.pb(aux); o[i].peso=W[i]; o[i].costoA=A[i]; o[i].costoB=B[i]; } sort(ALL(o)); reverse(ALL(o)); mset(dp,-1); while(!E.empty()){ e = E[SZ(E)-1]; E.pop_back(); mset(dp,-1); r.pb(f(0)); } reverse(ALL(r)); return r; }

컴파일 시 표준 에러 (stderr) 메시지

nile.cpp: In function 'll f(ll)':
nile.cpp:40:5: warning: unused variable 'aux' [-Wunused-variable]
   40 |  ll aux=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...