| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 46407 | 杨中琦 | 零件分组 | C++ | Accepted | 100 | 0 MS | 268 KB | 814 | 2022-07-13 13:04:32 |
#include<iostream> #include<algorithm> #include<stack> using namespace std; struct pa{ int s,w; }p[1005]; bool cmp(pa a,pa b){ if(a.w!=b.w) return a.w<b.w; if(a.s!=b.s) return a.s<b.s; } int main() { int n; cin>>n; for(int i=0;i<n;i++) cin>>p[i].s>>p[i].w; sort(p,p+n,cmp); int ans=1; int a[1005]={0}; int m=0; a[0]=p[0].s; for(int i=1;i<n;i++){ int f=0; for(int j=0;j<=m;j++){ if(p[i].s<a[j]){ f=1; } else{ f=0; a[j]=p[i].s; break; } } if(f==1){ m++; a[m]=p[i].s; ans++; } } cout<<ans; }