제출 #166628

#제출 시각아이디문제언어결과실행 시간메모리
166628abilK개의 묶음 (IZhO14_blocks)C++14
53 / 100
1087 ms4600 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int a[N], dp[1012][1012], table[20][1012], n, l[N]; void build(){ for(int i = 2;i <= n; i++){ l[i] = l[i / 2] + 1; } for(int i = 1;i <= n; i++){ table[0][i] = a[i]; } for(int i = 1;i <= l[n]; i++){ for(int j = 1;j <= n; j++){ table[i][j] = max(table[i - 1][j], table[i - 1][j + (1 << (i - 1))]); } } } int get(int left,int right){ int logg = l[right - left + 1]; return max(table[logg][left], table[logg][right - (1 << logg) + 1]); } main() { int k; scanf("%d%d", &n, &k); for(int i = 1;i <= n; i++){ scanf("%d", &a[i]); } build(); memset(dp, 0x3f3f3f3f,sizeof(dp)); for(int i = 1;i <= n; i++){ dp[1][i] = get(1, i); } for(int i = 2;i <= k; i++){ for(int j = i;j <= n; j++){ for(int p = j;p <= n; p++){ dp[i][p] = min(dp[i][p], dp[i - 1][j - 1] + get(j, p)); } } } cout << dp[k][n]; }

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

blocks.cpp:37:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
blocks.cpp: In function 'int main()':
blocks.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
blocks.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...