Submission #1135106

#TimeUsernameProblemLanguageResultExecution timeMemory
1135106UnforgettableplSandcastle 2 (JOI22_ho_t5)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef long double double; const int INF = 1e10; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,k; cin >> n >> k; vector<pair<int,int>> arr(n); for(auto&[a,b]:arr){cin>>b>>a;if(a==-1)a=INF;} sort(arr.begin(), arr.end()); arr.insert(arr.begin(),{0,0}); vector DP(n+1,vector(n+1,vector(n+1,(ld)INF))); DP[0][0][0]=0; auto solve = [&](ld x) { for(int i=1;i<=n;i++) { for(ld j=0;j<=x;j++) { DP[i][i][j]=INF; if(j)DP[i][i][j]=min(DP[i][i][j],DP[i-1][i-1][j-1]+(arr[i].first)/(j)); DP[i][i][j]=min(DP[i][i][j],DP[i-1][i-1][j]+(arr[i].second)/(x+1)); } for(ld j=x;j<=i;j++) { if(j!=i)DP[i][j][x]=INF; if(j)DP[i][j][x]=min(DP[i][j][x],DP[i-1][j-1][x]+(arr[i].second)/(x+1)); DP[i][j][x]=min(DP[i][j][x],DP[i-1][j][x]); } } return DP[n][k][x]; }; ld ans = INF; for(int x=0;x<=k;x++)ans=min(solve(x),ans); cout << setprecision(10) << ans << '\n'; }

Compilation message (stderr)

Main.cpp:5:14: error: multiple types in one declaration
    5 | typedef long double double;
      |              ^~~~~~
Main.cpp:5:21: error: declaration does not declare anything [-fpermissive]
    5 | typedef long double double;
      |                     ^~~~~~
Main.cpp: In function 'int32_t main()':
Main.cpp:19:42: error: 'ld' was not declared in this scope
   19 |     vector DP(n+1,vector(n+1,vector(n+1,(ld)INF)));
      |                                          ^~
Main.cpp:21:22: error: 'ld' is not a type
   21 |     auto solve = [&](ld x) {
      |                      ^~
Main.cpp: In lambda function:
Main.cpp:23:24: error: 'j' was not declared in this scope
   23 |             for(ld j=0;j<=x;j++) {
      |                        ^
Main.cpp:28:24: error: 'j' was not declared in this scope
   28 |             for(ld j=x;j<=i;j++) {
      |                        ^
Main.cpp: In function 'int32_t main()':
Main.cpp:36:7: error: expected ';' before 'ans'
   36 |     ld ans = INF;
      |       ^~~~
      |       ;
Main.cpp:37:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     for(int x=0;x<=k;x++)ans=min(solve(x),ans);
      |                          ^~~
      |                          abs
Main.cpp:38:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |     cout << setprecision(10) << ans << '\n';
      |                                 ^~~
      |                                 abs