80分求助!!!

P1068 [NOIP2009 普及组] 分数线划定

来个大佬帮忙吧!!!
by lwthree @ 2023-10-02 13:20:04


@[lwthree](/user/897873) 记得回复啊awa
by Hankler @ 2024-04-30 22:00:58


@[lwthree](/user/897873) 我想帮你,奈何本蒟蒻太菜了,以至于看不懂指针。。。。。。能不能解释一下写的是啥,球球乐QWQ ~~前提是你还需要帮助~~
by Hankler @ 2024-04-30 22:01:30


哎呀 都是七个月前的code了 我也不知道呀!
by lwthree @ 2024-05-01 11:42:46


@[lwthree](/user/897873) 好吧。。。我再看看
by Hankler @ 2024-05-01 13:54:52


@[lwthree](/user/897873) ``` 8 4 1001 99 1002 98 1003 97 1004 96 1005 95 1006 94 1007 93 1008 92 ``` 你试试这个,输出不对,但我不知道为啥。
by Hankler @ 2024-05-01 13:59:26


@[lwthree](/user/897873) ~~很好求助帖,使我学会指针~~ **强烈建议以后下标从 1 开始** 由于你的下标是从 0 开始的,但题目是从 1 开始,所以在 `int in=(int)floor(m*1.5);`这里,算出来的值 **下标是从 1 开始的!** 然而,你后面却把下标从 1 开始的值直接运用到下标从 0 开始的程序里。 应该把 `int in=(int)floor(m*1.5);` 改成 `int in=(int)floor(m*1.5)-1;` 我交了一下,[AC](https://www.luogu.com.cn/record/157610783)了。 ~~这应该不会棕吧。。。。。。~~
by Hankler @ 2024-05-01 20:06:20


@[lwthree](/user/897873) 把代码附上 ```cpp #include <bits/stdc++.h> using namespace std; struct tester { int score; int number; }testers[10500]; bool cmp(tester tester1, tester tester2) { if (!(tester1.score==tester2.score)) return tester1.score>tester2.score; else return tester1.number<tester2.number; } int main() { int n,m; cin>>n>>m; for (int i=0;i<n;i++) { cin>>testers[i].number>>testers[i].score; } sort(testers,testers+n,cmp); int in=(int)floor(m*1.5)-1; tester *pos=&testers[0]; tester *everypos[10500]; int poss=0; while (pos->score>=testers[in].score) { everypos[poss]=pos; pos++; poss++; } cout<<testers[in].score<<' '<<poss<<endl; for (int i=0;i<poss;i++) { cout<<everypos[i]->number<<' '<<everypos[i]->score<<endl; } return 0; } ```
by Hankler @ 2024-05-01 20:07:16


@[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873) @[lwthree](/user/897873)
by Hankler @ 2024-05-04 21:50:08


|