Submission #771212

#TimeUsernameProblemLanguageResultExecution timeMemory
771212Trisanu_DasGroup Photo (JOI21_ho_t3)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int ulta[5005][5005], dp[5005]; int main(){ int n; cin >> n; int a[n + 1], pos[n + 1]; for(int i = 0; i < n + 1; i++) { cin >> a[i]; pos[a[i]] = i; } for(int i = 2; i < n + 1; i++){ int cnt = 0; for(int j = i - 1; i > 0; i--){ if(a[j] > a[i]) cnt++; ulta[i][j] = ulta[i][j - 1] + cnt; } } for(int i = 1; i < n + 1; i++){ dp[i] = INT_MAX; for(int j = 0; j < i; j++) dp[i] = min(dp[i], dp[j] + ulta[1][i] - ulta[1][j] + ((i - j) * (i - j - 1)) / 2 - 2 * inv[j + 1][i]); } cout << dp[n] << '\n'; }

Compilation message (stderr)

cc1plus: error: '::main' must return 'int'
Main.cpp: In function 'int main()':
Main.cpp:25:48: error: 'inv' was not declared in this scope; did you mean 'int'?
   25 |                                            2 * inv[j + 1][i]);
      |                                                ^~~
      |                                                int