2023寒假训练Week3
Day 1
AcWing 4455. 出行计划
通过差分的方式计算出每个时刻做核酸产生的贡献,然后\(O(1)\)的回答就好了
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5+5;
int n , m , k , b[N];
int read(){
int x = 0 , f = 1 , ch = getchar();
while( (ch < '0' || ch > '9') && ch != '-' ) ch = getchar();
if( ch == '-' ) f = -1 , ch = getchar();
while( ch >= '0' && ch <= '9' ) x = ( x << 3 ) + ( x << 1 ) + ch - '0' , ch = getchar();
return x * f;
}
int main(){
n = read() , m = read() , k = read();
for( int c , t ; n ; n -- )
t = read() , c = read() , b[min( t+1 , N-1 )] -- , b[max(t-c+1,0)] ++;
for( int i = 1 ; i < N ; i ++ ) b[i] += b[i-1];
for( int q ; m ; m -- )
q = read() + k , printf("%d\n" , b[q] );
return 0;
}
2023牛客寒假算法基础集训营1
Day 2
AtCoder Beginner Contest 047
Day 3
2023牛客寒假算法基础集训营2
Day 4
补了上周的AtCoder Beginner Contest 043题解
Day 5
2023牛客寒假算法基础集训营3
春节假期
虽然没有要求写,但是还是要养成记录的习惯
Codeforces Round #847 (Div. 3)题解
AcWing杯 第 88 场周赛
AtCoder Beginner Contest 287
The 1st Universal Cup. Trial Contest
The 1st Universal Cup. Stage 1: Shenyang