Atcoder Beginner Contest153F (analog)

It should also be a segment tree / Fenwick tree update interval value of life monster to do

 1 #define HAVE_STRUCT_TIMESPEC
 2 #include<bits/stdc++.h>
 3 using namespace std;
 4 long long pre[200007];
 5 int main(){
 6     ios::sync_with_stdio(false);
 7     cin.tie(NULL);
 8     cout.tie(NULL);
 9     long long n,d,a;
10     cin>>n>>d>>a;
11     vector<pair<long long,long long> >v;
12     for( Int I = . 1 ; I <= n-; ++ I) {
 13 is          Long  Long X, Y;
 14          CIN >> >> X Y;
 15          Long  Long Z = (Y- . 1 ) / A + . 1 ;
 16          v.push_back ({X, Z});
 . 17      }
 18 is      Sort (v.begin (), v.end ());
 . 19      Long  Long ANS = 0 ;
 20 is      Long  Long SUM = 0 ;
 21 is      int R & lt = . 1 ; // not hit the recent range to 
22      for (int I = 0 ; I <n-; ++ I) {
 23 is          the while (R & lt <n-&& V [R & lt] .first <= V [I] .first + 2 * D)
 24              ++ R & lt;
 25          sum- pre = [I] ; // SUM is the total damage has been previously subjected to the current position 
26 is          V [I] .second- = SUM;
 27          IF (V [I] .second <= 0 )
 28              Continue ;
 29          SUM = V + [I] .second ; // cumulative damage 
30          pre [r] = + V [I] .second; // total damage r previous position bear 
31 is          ANS = + V [I] .second;
 32      }
33      cout << years;
34      return  0 ;
35 }

 

Guess you like

Origin www.cnblogs.com/ldudxy/p/12236129.html