제출 #874341

#제출 시각아이디문제언어결과실행 시간메모리
874341NHANGIOIBuilding Bridges (CEOI17_building)C++17
30 / 100
3033 ms2908 KiB
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second #define all(a) a.begin(),a.end() #define MASK(i) (1LL << (i)) #define count_bit(a) __builtin_popcountll(a) // đếm số bit đang bật #define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x #define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x #define SET_OFF(x, i) ((x) & ~MASK(i)) // tắt bit thứ i trong x #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define FORD(i,a,b) for(int i=(a);i>=(b);--i) #define endl '\n' using ll = long long; using ull = unsigned long long; using ld=long double; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l,ll r){ return l+rng()%(r-l+1);} const int BASE=257; const ll oo=1e18; const int INF=1e9+7; const ll MOD=1e9+7; const int NMAX=1e5+1; /* ,_ (OvO) /)_") /_/ */ signed main() { fastio; #define TASK "a" if(fopen(TASK".INP", "r")){ freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); }int n; cin>>n; int h[n+1],p[n+1]; FOR(i,1,n) cin>>h[i]; FOR(i,1,n) cin>>p[i]; int pre[n+1]; pre[0]=0; FOR(i,1,n) pre[i]=pre[i-1]+p[i]; int dp[n+1]; FOR(i,1,n) dp[i]=INF; dp[1]=0; FOR(i,2,n){ FORD(j,i-1,1){ int ans=dp[j]+((h[i]-h[j])*(h[i]-h[j]))+pre[i-1]-pre[j]; dp[i]=min(dp[i],ans); } }//FOR(i,1,n) cout<<dp[i]<<" "; cout<<dp[n]; cerr <<endl<< (1.0 * clock() / CLOCKS_PER_SEC) << endl; return 0; }

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

building.cpp: In function 'int main()':
building.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
building.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(TASK".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...