|
@@ -1,5 +1,7 @@
|
|
|
#include <iostream>
|
|
|
#include <vector>
|
|
|
+#include <string>
|
|
|
+#include <algorithm>
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
@@ -8,6 +10,15 @@ struct Grade {
|
|
|
int Score;
|
|
|
};
|
|
|
|
|
|
+bool compare(Grade a, Grade b) {
|
|
|
+ if (a.Score > b.Score) {
|
|
|
+ return true;
|
|
|
+ } else if (a.Score < b.Score) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return a.Id < b.Id;
|
|
|
+}
|
|
|
+
|
|
|
int main() {
|
|
|
int N = 0, M = 0, G = 0;
|
|
|
int *questions;
|
|
@@ -31,10 +42,9 @@ int main() {
|
|
|
total = 0, scoreIndex = 0;
|
|
|
cin >> id;
|
|
|
cin >> answer;
|
|
|
- answer = answer > M ? M : answer;
|
|
|
for (int j = 0; j < answer; j++) {
|
|
|
cin >> scoreIndex;
|
|
|
- total += questions[scoreIndex];
|
|
|
+ total += questions[scoreIndex - 1];
|
|
|
}
|
|
|
if (total < G) {
|
|
|
continue;
|
|
@@ -43,11 +53,13 @@ int main() {
|
|
|
grade.push_back(tempGrade);
|
|
|
}
|
|
|
|
|
|
+ sort(grade.begin(), grade.end(), compare);
|
|
|
+
|
|
|
+ cout << grade.size() << endl;
|
|
|
for (int i = 0; i < (grade.size()); i++) {
|
|
|
- cout << "id: " << grade.at(i).Id << "; scoreIndex: " << grade.at(i).Score << endl;
|
|
|
+ cout << grade.at(i).Id << " " << grade.at(i).Score << endl;
|
|
|
}
|
|
|
|
|
|
- // free
|
|
|
free(questions);
|
|
|
grade.clear();
|
|
|
}
|