- 2025-10-3普及day2
论lk上课写的代码
- @ 2025-10-3 21:00:56
左边是lk上课写的,右边是他自己改的,写得太好了!!!
赶快转发

3 条评论
-
郭伊哲 LV 4 @ 2025-10-3 21:13:00上面的函数怎么写?
-
@ 2025-10-3 21:12:47#include<bits/stdc++.h> using namespace std; int main(){ freopen("taxi.in","r",stdin); freopen("taxi.out","w",stdout); ios::sync_with_stdio(0); cin.tie(nullptr); int a,b; cin>>a>>b; int c=a+b; vector<int> e(c); vector<int> d(c); for(int i=0;i<c;i++) cin>>e[i]; for(int i=0;i<c;i++) cin>>d[i]; vector<int> f; for (int i=0;i<c;i++) if(d[i]1) f.push_back(e[i]); vector<int> g(b,0); for (int i=0;i<c;i++){ if (d[i]0){ int h=e[i]; auto k=upper_bound(f.begin(),f.end(),h); int n=k-f.begin(); if(n0)g[n]++; else if(nb)g[n-1]++; else{ int l=h-f[n-1]; int m=f[n]-h; if(l<m) g[n-1]++; else if(m<l) g[n]++; else g[n-1]++; } } } for(int i=0;i<b;i++){ if(i>0)cout<<" "; cout<<g[i]; } cout<<endl; return 0; }
-
@ 2025-10-3 21:04:32
👍
- 1