제출 #1110855

#제출 시각아이디문제언어결과실행 시간메모리
1110855salmonSki 2 (JOI24_ski2)C++14
42 / 100
2069 ms317884 KiB
#include <bits/stdc++.h> using namespace std; int N, K, H; long long int memo[400][400][400]; vector<pair<int,int>> v; int h,h1; vector<int> vh; int cost[400]; const int inf = 1.1e9; int sise[400]; int main(){ scanf(" %d",&N); scanf(" %d",&K); for(int i = 0; i < N; i++){ scanf(" %d",&h); scanf(" %d",&h1); v.push_back({h,h1}); } sort(v.begin(),v.end()); int p = -1; for(int i = 0; i < N; i++){ if(v[i].first <= p){ p++; vh.push_back(p); } else{ p = v[i].first; vh.push_back(p); } } H = vh.size(); cost[0] = inf; sise[0] = 0; auto it = 0; for(int i = 0; i < N; i++){ while(vh[it] != v[i].first){ it++; cost[it] = cost[it - 1]; sise[it] = 0; } cost[it] = min(cost[it], v[i].second); sise[it]++; } while(it != H - 1){ it++; cost[it] = cost[it - 1]; sise[it] = 0; } for(int i = 0; i < H; i++){ for(int j = 0; j <= N; j++){ for(int k = 0; k <= N; k++){ memo[i][j][k] = -1; } } } for(int i = H - 1; i >= 0; i--){ if(i != H - 1){ } for(int j = 0; j <= N; j++){ for(int k = 1; k <= N; k++){ if(i == H - 1){ memo[i][j][k] = max(0,(j + sise[i] - k)) * (long long int)cost[i]; } else if(i == 0){ int num = max(0, j + sise[i] - k); memo[i][j][k] = inf * (long long int)inf; if(memo[i + 1][num][k] != -1){ memo[i][j][k] = min(memo[i][j][k], memo[i + 1][num][k] + num * (long long int)K); } } else{ int num = max(0, j + sise[i] - k); memo[i][j][k] = inf * (long long int)inf; for(int l = 0; l <= num; l++){ if(memo[i + 1][num - l][l + k] != -1){ memo[i][j][k] = min(memo[i][j][k], memo[i + 1][num - l][l + k] + (num - l) * (long long int) K * (vh[i + 1] - vh[i]) + l * (long long int)cost[i - 1] ); } } } //printf("%d ",memo[i][j][k]); } //printf("\n"); } //printf("\n"); } printf("%lld",memo[0][0][1]); }

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

Main.cpp: In function 'int main()':
Main.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
Main.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf(" %d",&K);
      |     ~~~~~^~~~~~~~~~
Main.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf(" %d",&h);
      |         ~~~~~^~~~~~~~~~
Main.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf(" %d",&h1);
      |         ~~~~~^~~~~~~~~~~
#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...