#include<iostream> #include<algorithm> #include<string> using namespace std; struct Student { int number; int score; }; Student s[10000]; bool compare(const Student s1, const Student s2) { return s1.number < s2.number; } int main() { int N, M; cin >> N >> M; for (int i = 0; i < N + M; ++i) { cin >> s[i].number >> s[i].score; } sort(s, s + N + M, compare); for (int i = 0; i < N + M; ++i) { cout << s[i].number << " " << s[i].score << endl; } } |
Double click to view unformatted code.