这道题可以用貌似可以用结构体做 STRUCT 鄙人不会 求教

P1085 [NOIP2004 普及组] 不高兴的津津

```cpp struct node { int a,b; }data[23333]; for (int i=1;i<=n;i++) scanf("%d%d",&data[i].a,&data[i].b); ```
by 苣蒻yz @ 2016-08-31 20:45:45


```cpp #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include<cstdlib> #include<ctime> #include<queue> #define N 100010 using namespace std; int m,n; inline int read()**//读入优化不解释,看不明白用cin或scanf** { char ch=getchar(); int data=0,f=1; while (ch<'0'||ch>'9') { ch=getchar(); if(ch=='-') f=-1; } do { data=data*10+ch-'0'; ch=getchar(); } while (ch>='0'&&ch<='9'); return data*f; } struct node { int id,v; }b[50000];//id 记录星期几,v记录上课总的时间 bool com(node a,node b){ if(a.v==b.v ) return a.id<b.id;//上课时间相同就把天数小的排在前 return a.v>b.v; //上课时间多的排在前 } int main() { int i,j; for (i=1;i<=7;i++){ int x=read(),y=read(); b[i].id=i; b[i].v=x+y; } sort(b+1,b+8,com);//STL大法好o(^▽^)o if(b[1].v<=8 ) cout<<0; else cout<<b[1].id; return 0; } ```
by 欢迎拨打10086 @ 2016-09-01 15:05:35


考古
by lion0514 @ 2020-05-23 19:16:18


|