|
|
Общий форумHelp me: Wrong answer in test #6 Wrong answer in test №20, help Edited by author 10.03.2022 01:08 0 0 0 0 0 0 0 0 10 17 check this what's the test case 7???? All the cases given hv been passed alr... #include <iostream> using namespace std; int main() { int n, k, *arr,raz,y=0,ost=0; cin >> n >> k; arr = new int[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n; i++) { raz = 5 - arr[i]; if (raz >= 0) { y = y + raz; } else { y = y; ost = ost + raz * -1; } } cout << ost << " " << y; return 0; } > raz = 5 - arr[i]; Why "5" ? ahahah I'm stupid :D Thanks) the task could be solved by shorter way // 2022-03-08.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int droid = 0, bum = 0; int tempBum; for (int i = 0; i < n; i++) { cin >> tempBum; if (tempBum > k) { bum += tempBum - k; } if (k > tempBum) { droid += k - tempBum; } } cout << bum << " " << droid; } try 12.12.12 1 Not a floating point number 5 7 1 2 2 3 1 4 4 5 1 5 2 5 4 3 4 3 4 7 2 ans: 1 1 2 3 Thank you so much! This really helped me debug :). On the first sight i thought i'd need O(3 ^ 16) but the problem is much easier. if you WA on #3 ,please use unsigned __int64 and high-accuracy if you WA on #9 ,try this 2 10 3 The answer is 0 Edited by author 03.03.2022 10:56 cnt = 0 a = int(input()) a1 = list(map(int, input().split())) b = int(input()) b1 = list(map(int, input().split())) c = int(input()) c1 = list(map(int, input().split())) for i in a1 : if i in b1 and c1 and a1 : cnt += 1 print(cnt) what is wrong? tells "wrong answer" Probably you're getting overflow Arithmetic average is not exacltly x. Due to the rounding arithmetic average can be x + 0.01 or even x + 0.04999 \/ \/ /\ /\ 8 4 0 0 2 2 2 0 0 2 0 3 2 5 2 3 0 5 1 2 3 4 5 6 7 8 Answer: "NO" Spent a hour to realise that you don't need to count left and right parts of figure, only middle Edited by author 27.02.2022 15:58 I investigated on internet, but most of the answers were putting a type of character that breaks the cycle, but in the input example there´s no character and it´s not enough with a "while(cin >> n)" pls help if copypast test text, it read a blank string as EOF by some reason Edited by author 26.02.2022 22:11Let's sequence S(n) = {s[1], s[2], ..., s[n]} is optimal sequence for the first n steps. L[i] is max number when we can get one space using S(n) for any number in range [1..L[i]]: firstly, we apply s[n], then s[n-1] and etc. Now let's get next s[n+1]. Suppose we found s[n+1] and want get L[n+1]. Always L[n+1] + 1 = q*s[n+1] + r, 0<=r<s[n+1]. L[n+1] is max number => for L[n+1] + 1 we need at least n+2 steps => q + r >= L[n] + 1. But L[n+1] + 1 is min number when using S(n+1) we can't get one space => r->max, q->min => r = s[n+1] - 1, q = L[n] + 1 - r => L[n+1] + 1 = q * s[n+1] + r => L[n+1] = (L[n] - s[n+1] + 2) * s[n+1] + s[n+1] - 2 -> max (where arg is s[n+1]) => s[n+1] = (L[n] + 1) / 2 But using symmetry we can give s[n+1] = floor(L[n] / 2) + 1 (we choice bigger number because s[2] > 1). => L[n+1] = q * s[n+1] + r - 1, q = L[n] + 1 - r, r = s[n+1] - 1.
Edited by author 26.02.2022 01:27 Edited by author 26.02.2022 01:27 My program runs any tests from other topics perfectly, but something is wrong with the task 1. Sounds like madness. Edited by author 24.02.2022 23:04 Edited by author 24.02.2022 23:05 Pay attention, that points given in order A, B, C. That means that angle of your triangle must equal to angle BAC Edited by author 21.02.2022 17:07 George_Aloyan[PTS_Obninsk][MIPT][IPG][ALIGN][YANDEX] WA9 [1] // Задача 1184. Cable Master 11 янв 2012 22:27 Set types as long long for variables used as sum of cables lengths For me, what worked was replacing "%i"'s with "%d"'s in scanf's. :) |
|
|