fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cmath>
  4. #include <string>
  5. #include <set>
  6. #include <unordered_set>
  7. #include <vector>
  8. #include <map>
  9. #include <unordered_map>
  10. #include <deque>
  11. #include <queue>
  12. #include <stack>
  13. #include <random>
  14. #include <time.h>
  15. #include <utility>
  16. #include <fstream>
  17. #include <cstring>
  18. using namespace std;
  19. #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  20. #define mofile(s) freopen(s,"r",stdin)
  21. #define outfile(s) freopen(s,"w",stdout)
  22. #define ll long long
  23. #define ii pair<int,int>
  24. #define iii pair<int,ii>
  25. #define fi first
  26. #define se second
  27. #define B bool
  28. #define ST stack
  29. #define DQ deque
  30. #define Q queue
  31. #define S string
  32. #define Ma map
  33. #define UM unordered_map
  34. #define SE set
  35. #define str(x) to_string(x)
  36. #define all(a) (a).begin(),(a).end()
  37. #define FOR(i,l,r) for(int i=l;i<=r;++i)
  38. #define FOD(i,l,r,d) for(int i=r;i>=l;i+=d)
  39. #define ppcnt(x) __builtin_popcountll(x)
  40. #define parity(x) __builtin_parityll(x)
  41. #define lead0(x) __builtin_clzll(x)
  42. #define LOG2 __lg(x)
  43. #define tr0(x) __builtin_ctzll(x)
  44. #define fiset(x) __builtin_ffsll(x)
  45. #define pb push_back
  46. #define tron(x) setprecision(x)
  47. #define het return 0
  48. const int MOD=1e9+7;
  49. const int maxn=1e5+5;
  50. int t[maxn],r[maxn],dp[maxn];
  51. void open(){
  52. mofile("dptick.inp"); outfile("dptick.out");
  53. }
  54. int main(){
  55. fast;
  56. //open();
  57. int n; cin>>n;
  58. for(int i=1;i<=n;++i) cin>>t[i];
  59. for(int i=1;i<n;++i) cin>>r[i];
  60. memset(dp,0x3f,sizeof(dp));
  61. dp[0]=0;
  62. for(int i=0;i<n;++i){
  63. dp[i+1]=min(dp[i+1],dp[i]+t[i+1]);
  64. dp[i+2]=min(dp[i+2],dp[i]+r[i+1]);
  65. }
  66. cout<<dp[n];
  67. return 0;
  68. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty