2 条题解

  • 0
    @ 2025-10-8 16:59:19
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    const int N = 2e5 + 10;
    LL t[N], p[N], ans[N];
    int main()
    {
        int n;scanf("%d", &n);
        for (int i = 1; i <= n; i++)scanf("%lld", &t[i]);
        for (int i = 1; i <= n; i++)scanf("%lld", &p[i]);
        ans[1] = t[1];
        for (LL i = n, x = 0; i > 1; i--){
            x = x + p[i];
            if (t[i] + x < ans[1])ans[1] = t[i] + x;
        }
        for (int i = 2; i <= n; i++){
            ans[i] = ans[i - 1] + p[i - 1];
            if (t[i] < ans[i])ans[i] = t[i];
        }
        int q;scanf("%d", &q);
        for (int i = 1, x; i <= q; i++){
            scanf("%d", &x);
            printf("%lld\n", ans[x]);
        }
        return 0;
    }
    
    • 0
      @ 2025-10-8 16:59:09
      #include <bits/stdc++.h>
      using namespace std;
      typedef long long LL;
      const int N = 2e5 + 10;
      LL t[N], p[N], ans[N];
      int main()
      {
          int n;scanf("%d", &n);
          for (int i = 1; i <= n; i++)scanf("%lld", &t[i]);
          for (int i = 1; i <= n; i++)scanf("%lld", &p[i]);
          ans[1] = t[1];
          for (LL i = n, x = 0; i > 1; i--){
              x = x + p[i];
              if (t[i] + x < ans[1])ans[1] = t[i] + x;
          }
          for (int i = 2; i <= n; i++){
              ans[i] = ans[i - 1] + p[i - 1];
              if (t[i] < ans[i])ans[i] = t[i];
          }
          int q;scanf("%d", &q);
          for (int i = 1, x; i <= q; i++){
              scanf("%d", &x);
              printf("%lld\n", ans[x]);
              }
          return 0;
      }
      • 1

      信息

      ID
      1905
      时间
      1000ms
      内存
      256MiB
      难度
      9
      标签
      递交数
      9
      已通过
      6
      上传者