fork download
  1. class Solution {
  2. public:
  3. int twoCitySchedCost(vector<vector<int>>& cost) {
  4. int n=cost.size();
  5. vector <int> dp(n+1,1e8);
  6. dp[0]=0;
  7. for (int i=0;i<n;i++)
  8. {
  9. for (int j=n;j>=1;j--)
  10. {
  11. dp[j]=min(dp[j-1]+cost[i][0],dp[j]+cost[i][1]);
  12. }
  13. dp[0]=dp[0]+cost[i][1];
  14. }
  15. return dp[n/2];
  16. }
  17. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:26: error: ‘vector’ has not been declared
     int twoCitySchedCost(vector<vector<int>>& cost) {
                          ^~~~~~
prog.cpp:3:32: error: expected ‘,’ or ‘...’ before ‘<’ token
     int twoCitySchedCost(vector<vector<int>>& cost) {
                                ^
prog.cpp: In member function ‘int Solution::twoCitySchedCost(int)’:
prog.cpp:4:15: error: ‘cost’ was not declared in this scope
         int n=cost.size();
               ^~~~
prog.cpp:5:9: error: ‘vector’ was not declared in this scope
         vector <int> dp(n+1,1e8);
         ^~~~~~
prog.cpp:5:17: error: expected primary-expression before ‘int’
         vector <int> dp(n+1,1e8);
                 ^~~
prog.cpp:6:9: error: ‘dp’ was not declared in this scope
         dp[0]=0;
         ^~
prog.cpp:11:23: error: ‘min’ was not declared in this scope
                 dp[j]=min(dp[j-1]+cost[i][0],dp[j]+cost[i][1]);
                       ^~~
stdout
Standard output is empty