###### tags: `APCS` `c++` `題解` # 題解 zerojudge b966與zerojudge f855: 第 3 題 線段覆蓋長度 APCS ```cpp= #include<bits/stdc++.h> using namespace std; short int line[10000005]={0}; int main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int N,l,r,ans=0; cin>>N; while(N--){ cin>>l>>r; l++;r++;//保留line[0],第16行會用到 line[l]+=1; line[r]-=1; } for(int i=1;i<=10000001;i++){ line[i]+=line[i-1]; if(line[i]>0) ans++; } cout<<ans<<'\n'; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up