|
|
вернуться в форумWA#8 - Time limit C++ Послано vladi 17 окт 2013 18:19 #include <iostream> using namespace std; int main() { int i, j, k = 0, n, m, stud; scanf("%d", &n); int *prepod = new int[n]; for (i = 1; i<=n; i++) { scanf("%d", &prepod[i]); if (i>=2) { if (prepod[i] == prepod[i-1]) prepod[i-1] = -1; } } scanf("%d", &m); for (i = 1; i<=m; i++) { scanf("%d", &stud); for (j=1; j<=n; j++) { if (stud == prepod[j]) k++; }
} printf("%d", k); return 0; } Edited by author 20.10.2013 06:07 Edited by author 20.10.2013 06:08 Edited by author 20.10.2013 06:08 Re: WA#8 - Time limit C++ Послано vladi 27 окт 2013 03:39 #include <iostream> using namespace std; int main() { int i, j, k = 0, n, m, stud, first = 0, last, temp = 0; scanf("%d", &n); int *prepod = new int[n]; for (i = 1; i<=n; i++) { scanf("%d", &last); if (first != last) { first = last; temp++; prepod[temp] = last; } } scanf("%d", &m); for (i = 1; i<=m; i++) { scanf("%d", &stud); for (j=1; j<=temp; j++) { if (stud == prepod[j]) { k++; break; } }
} printf("%d", k); system("pause"); return 0; } |
|
|