|
|
Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | Wrong answer. Help pls!! C++ | TIU_Sarexer | 1991. Битва у болота | 9 мар 2022 01:34 | 4 | #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; } | easy translation | Mattiev Jamol | 1991. Битва у болота | 24 янв 2022 14:41 | 4 | if(a[i]<k){ ans+=k-a[i]; } else{ ans1+=a[i]-k; } I think that this problem is easy enough to try to make the solution as efficient as possible. My consideration notes: 1. You can make it without using arrays, because the local information that you get is enough to generate the answer. 2. I think that it is worth trying to make the speaking variable names. It will certainly require additional time, but I think, it should pay off in the future. Any good book (about Pascal for example) will tell about it Ho do they get 0.001 seconds? | help me, find mistake, 5 test | buyolitsez | 1991. Битва у болота | 13 ноя 2018 21:04 | 1 | #include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int n,k; cin >> n >> k; int dontused=0,dontdie=0; int f; for(int i=0;i<n;i++) { cin >> f; if(k>f) { dontdie+=k-f; } if(k<f) { dontused+=f-k; } } cout << dontused << " " << dontdie; return 0; } | what mistake? | Evgenii | 1991. Битва у болота | 13 июн 2017 18:03 | 2 | program pr; Var n,k,i,s,q:integer; a:array[1..100000] of integer; b:array[1..100000] of integer; Begin q:=0; read(n,k); for i:=1 to n do readln(a[i]); for i:=1 to n do b[i]:=k-a[i]; for i:=1 to n do begin if b[i]<0 then s:=abs(b[i]); if b[i]>=0 then q:=q+b[i] ; end; write(s,' ',q) End. | 1991. Битва у болота // please,need help! where is the mistake& | kodirmullaboyev | 1991. Битва у болота | 25 янв 2016 12:34 | 1 | import java.util.Scanner; /** * Created by Oxygen! on 25.01.2016. */ public class BitvaUBolota1991Var2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=0,y=0; int n=sc.nextInt(); int k=sc.nextInt(); int a[]=new int[n]; for(int i=0; i<n; i++) { a[i]=sc.nextInt(); if(a[i]<=0) { y+=k-a[i]; } else { x+=a[i]-k; } System.out.println(x+" "+y); } } } | admin plz help!! | Shubham Murarka | 1991. Битва у болота | 20 сен 2015 18:24 | 2 | what is the range of "n" ?? I am not the admin, but I will help :) From 1 to 10000. | I have AC in Java 1.7 | Axmadjon | 1991. Битва у болота | 6 май 2014 19:09 | 1 | | To admins | Silent | 1991. Битва у болота | 4 ноя 2013 14:48 | 5 | я знаю что она решается, у меня AC. я говорю про то, что на Go 1.1 простой способ считывания входных данных работает некорректно, и прошу разобраться - это бага fmt.Scanf или что-то с форматом test #3. Try to read integers in the first string using format "%v %v\n" instead of "%v %v". It's not evident, but... it works! If solution reads the first string using fmt.Scanf("%v %v\n",&n,&k) then it gets AC. Thanks, Sandro (USU)! |
|
|
|