2 条题解

  • 4
    @ 2025-11-3 17:27:16
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const ll N=1e6+5;
    void solve(){
        ll n,T;cin>>n>>T;
        ll x=0;
        while(n--){
            ll t,k;cin>>t>>k;
            if(k>=x-T+t){
                x+=t;
                continue;
            }        
            if(k>=x-T) x=T+k+1;
            else x++;
        }
        cout<<x<<'\n';
    }
    int main(){
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        ll _=1;
    //    cin>>_;
        while(_--){
            solve();
        }
        return 0;
    }
    
    • 3
      @ 2025-11-3 20:01:31
      #include <stdio.h>
      int main(){
          long long int n,t,x=0,a,k;
          scanf("%lld%lld",&n,&t);
          while(n--){
              scanf("%lld%lld",&a,&k);
              if(t-a+k>=x)x+=a;
              else if(x<t+k+1){
                  x=t+k+1;
              }
              else x++;
          }
          printf("%lld",x);
      }
      
      • 1

      信息

      ID
      1168
      时间
      1000ms
      内存
      256MiB
      难度
      7
      标签
      递交数
      214
      已通过
      51
      上传者