有 n 个县和 m 个候选人,每个县都有一个候选人的排名。每个县会给所有没有弃权的候选人中,在它们那里排名最靠前的投一票。得票最多的候选人当选,特殊地,若多个人得票相同,编号更小的候选人当选。
求:
-
若没有候选人弃权,哪个候选人当选。
-
最少几个候选人弃权可以使得编号为 k 的候选人当选。
每一问占当前测试点的 50% 分数。
#include "testlib.h"
int main(int argc, char* argv[]) {
registerTestlibCmd(argc, argv);
int out1=ouf.readInt(), out2=ouf.readInt();
int ans1=ans.readInt(), ans2=ans.readInt();
if(out1==ans1&&out2==ans2)
quitf(_ok,"OK, both test cases are solved.");
else if(out1==ans1)
quitp(0.5,"Only the first case is solved: expected %d %d, found %d %d.",ans1,ans2,out1,out2);
else if(out2==ans2)
quitp(0.5,"Only the second case is solved: expected %d %d, found %d %d.",ans1,ans2,out1,out2);
else quitf(_wa,"Wrong answer: expected %d %d, found %d %d.",ans1,ans2,out1,out2);
}