fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int code(string s) {
  5. int codeAscii = 0;
  6. for (int i = 0; i < s.size(); ++i) {
  7. codeAscii += (int)s[i];
  8. }
  9. return codeAscii;
  10. }
  11.  
  12. int main() {
  13. string s[100];
  14. int n;
  15. cin >> n;
  16. int v[100];
  17. int w[100] = {0};
  18. for (int i = 0; i < n; ++i) {
  19. cin >> s[i];
  20. w[i] = code(s[i]);
  21. }
  22. for (int i = 0; i < n; ++i) {
  23. cin >> v[i];
  24. }
  25. for (int i = 0; i < n - 1; ++i) {
  26. for (int j = i + 1; j < n; ++j) {
  27. if (v[i] > v[j]) {
  28. swap(v[i], v[j]);
  29. swap(s[i], s[j]);
  30. }
  31. }
  32. }
  33. for (int i = 0; i < n - 1; ++i) {
  34. for (int j = i + 1; j < n; ++j) {
  35. if (w[i] > w[j]) {
  36. swap(w[i], w[j]);
  37. }
  38. }
  39. }
  40. int cnt = 0;
  41. for (int i = 0; i < n; ++i) {
  42. if (w[i] != v[i]) {
  43. ++cnt;
  44. }
  45. }
  46. if (cnt == 0) {
  47. cout << "CORECT";
  48. } else {
  49. cout << "EROARE";
  50. cout << "\n" << cnt;
  51. }
  52. return 0;
  53. }
  54.  
Success #stdin #stdout 0.01s 5320KB
stdin
5
Abc cda zzz FROEK Ciup
375 262 401 297 366
stdout
EROARE
1