Borderou de evaluare (job #818468)

Utilizator avatar DragonulCosmic Nerdvana 5 Calin Dragos Andrei DragonulCosmic IP ascuns
Problemă Ktlon (clasa a 5-a) Compilator cpp-32
Rundă mega_maraton5 Status evaluat
Dată 5 apr. 2025 10:45:49 Scor 100

Raport evaluator

Compilare: main.cpp: In function 'int main()': main.cpp:3:1093: warning: 'position' may be used uninitialized [-Wmaybe-uninitialized] 3 | using namespace std; ifstream cin("ktlon.in"); ofstream cout("ktlon.out"); int arr_f[10001], arr_r[10001]; int main() { int cer, n, p, x, Max1, Max2, cnt = 0; cin >> cer >> n >> p; if (cer == 1) { for (int i = 1; i <= p; i++) { Max1 = 0, Max2 = 0; for (int j = 1; j <= n; j++) { cin >> x; if (x > Max1) Max1 = x; } for (int j = 1; j <= n; j++) { cin >> x; if (x > Max2) Max2 = x; } if (Max2 > Max1) cnt++; } cout << cnt; } else if (cer == 2) { int genSumF = 0, genSumR = 0; for (int i = 1; i <= p; i++) { int sumf = 0, sumr = 0, position; for (int j = 0; j < n; j++) cin >> arr_f[j]; for (int j = 0; j < n; j++) cin >> arr_r[j]; sort(arr_f, arr_f + n); sort(arr_r, arr_r + n); Max1 = arr_f[n-1]; Max2 = arr_r[n-1]; if (Max1 > Max2) { for (int j = n-1; j >= 0; j--){ if (arr_f[j] > Max2) sumf = sumf + arr_f[j]; else{ position = j; break; } } position++; for (int j = position; j < n; j++) sumr = sumr + arr_r[j]; genSumF = genSumF + (sumf - sumr); } else if (Max2 > Max1){ for (int j = n - 1; j >= 0; j--) { if (arr_r[j] > Max1) sumr = sumr + arr_r[j]; else{ position = j; break; } } position++; for (int j = position; j < n; j++) sumf = sumf + arr_f[j]; genSumR = genSumR + (sumr - sumf); } } cout << max(genSumR, genSumF); } return 0; } | ~~~~~~~~^~ main.cpp:3:530: note: 'position' was declared here 3 | using namespace std; ifstream cin("ktlon.in"); ofstream cout("ktlon.out"); int arr_f[10001], arr_r[10001]; int main() { int cer, n, p, x, Max1, Max2, cnt = 0; cin >> cer >> n >> p; if (cer == 1) { for (int i = 1; i <= p; i++) { Max1 = 0, Max2 = 0; for (int j = 1; j <= n; j++) { cin >> x; if (x > Max1) Max1 = x; } for (int j = 1; j <= n; j++) { cin >> x; if (x > Max2) Max2 = x; } if (Max2 > Max1) cnt++; } cout << cnt; } else if (cer == 2) { int genSumF = 0, genSumR = 0; for (int i = 1; i <= p; i++) { int sumf = 0, sumr = 0, position; for (int j = 0; j < n; j++) cin >> arr_f[j]; for (int j = 0; j < n; j++) cin >> arr_r[j]; sort(arr_f, arr_f + n); sort(arr_r, arr_r + n); Max1 = arr_f[n-1]; Max2 = arr_r[n-1]; if (Max1 > Max2) { for (int j = n-1; j >= 0; j--){ if (arr_f[j] > Max2) sumf = sumf + arr_f[j]; else{ position = j; break; } } position++; for (int j = position; j < n; j++) sumr = sumr + arr_r[j]; genSumF = genSumF + (sumf - sumr); } else if (Max2 > Max1){ for (int j = n - 1; j >= 0; j--) { if (arr_r[j] > Max1) sumr = sumr + arr_r[j]; else{ position = j; break; } } position++; for (int j = position; j < n; j++) sumf = sumf + arr_f[j]; genSumR = genSumR + (sumr - sumf); } } cout << max(genSumR, genSumF); } return 0; } | ^~~~~~~~
Test Timp execuție Memorie folosită Mesaj Punctaj/test
1 1 ms 245 kb OK 5
2 1 ms 507 kb OK 5
3 1 ms 249 kb OK 5
4 39 ms 507 kb OK 5
5 219 ms 249 kb OK 5
6 249 ms 245 kb OK 5
7 249 ms 249 kb OK 5
8 1 ms 245 kb OK 5
9 1 ms 245 kb OK 5
10 1 ms 249 kb OK 5
11 8 ms 143 kb OK 5
12 19 ms 270 kb OK 5
13 59 ms 249 kb OK 5
14 1 ms 270 kb OK 5
15 69 ms 245 kb OK 5
16 199 ms 524 kb OK 5
17 208 ms 249 kb OK 5
18 309 ms 512 kb OK 5
19 319 ms 245 kb OK 5
20 309 ms 270 kb OK 5
Punctaj total 100