Общий форумCould somebody who solved this problem give some tests to me? WA #7 :( Also asking for some random tests, because it's hard to check the solution. random test: 25 7 3 4.0671982122 good luck =) 100 2 20 0.00000 100 98 1 0.12311156 85 17 53 2.1738219 #include <stdio.h> int main(){ int a,b,c; scanf("%d",&a); scanf("%d",&b); scanf("%d",&c); if (a>b){ if (b>c){ printf("%d",c-(a*b)); } else{ printf("%d",b-(a*c)); } } if(b>a){ if (a<c){ printf("%d",a-(c*b)); } } return 0; } 1) a,b,c sequence is already sorted. 2) Try "1 1 1" input. Answer is -1. I used next_permutation and get AC i used next_permutation and got TLE Hi, I made a countries ranklist here: http://acmtimusru.appspot.com It lists the countries by rating, solved, users or last ac, where: - rating = sum(user.rating) for user in a country - solved = sum(user.solved) for user in a country - users = count of users in a country - last ac = the most recent accepted submission of any user in a country Also, clicking on a country gives you a ranklist of users in that specific country. The ranklists are updated hourly. Enjoy! Edited by author 24.03.2020 14:51That's nice. Thank your for sharing your effort with us! God bless Antarctica! Edited by author 24.03.2020 19:53 Can anybody help Edited by author 20.03.2020 19:35 I don't know why my solution is failing on test case 1, I have tested against all available test cases with correct answer , but cannot pass test case 1, can anybody please tell what is test case 1. Is it possible to change the judge id? Thanks What is test case 1? It's the same as the given sample input. But what if i have the same answer that in sample, and get WA1? import java.util.Scanner; public class javasucc { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int h = 2, s = 10; for(int i=0; i<n; i++) { int a = in.nextInt(); String b = in.next(); if(b=="hungry"){ if(a>h) {h = a;} } else if(b=="satisfied"){ if(a<s) {s = a;} } } if(h >= s) System.out.println("Inconsistent"); else System.out.println(s); } } and the problem is that program doesn't want to do if and i can't change s to a 1) I wasn't crying for help though but just was wondering why 2) Thanks for the link, the problem was actually in "==" n=int(input()) a=[] for i in range(n): s=input() if(s[0]=="A" or s[0]=="P" or s[0]=="O" or s[0]=="R"): a.append(0) elif(s[0]=="B" or s[0]=="M" or s[0]=="S"): a.append(1) else: a.append(2) t=0 for i in range(n): if(i+1<n): t=t+abs(a[i]-a[i+1]) print(t) #include <stdio.h> #include <map> using namespace std; int main() { int ans, sum, ost, s; long int full, i; map <long int, int> sums; for (i = 1; i <= 1000000000; i++) { sum = 0; full = i; do { ost = full % 10; full /= 10; sum += ost; } while (full > 0); sums[i] = sum; } for (s = 1; s <= 81; s++) { ans = 0; for (i = 1; i <= 1000000000; i++) if (sums[i] == s) ans++; printf("{%ld}, ", ans); } } it will give you {10}, {...}, ... , {...}, vector that you can use for getting AC with O(1). Edited by author 11.03.2020 14:40 Edited by author 11.03.2020 14:44 "The numbers are arranged in non-decreasing order (0 ≤ a ≤ b ≤ c ≤ 100)." I my opinion, reading this we assume that the input will already be sorted. #include <iostream> #include <string> using namespace std; int main() { int hun = 2, sat = 10, n; cin >> n; string s; for (int i = 0, num; i < n; i++) { cin >> num >> s; if (s == "hungry") if (num > hun) hun = num; if (s == "satisfied") if (num < sat) sat = num; } if (hun >= sat) cout << "Inconsistent"; else cout << sat; } import java.io.PrintWriter; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Scanner; public class Task_1263 { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); String str = in.nextLine(); int candidateCount = Integer.valueOf(str.substring(0, 1)); int votersCount = Integer.valueOf(str.substring(2)); int[] votersForCandidates = new int[candidateCount]; double[] votersPercents = new double[candidateCount]; int voter; for (int i = 0; i < votersCount; i++) { voter = Integer.valueOf(in.nextLine()); votersForCandidates[voter - 1]++; } for (int i = 0; i < candidateCount; i++) { votersPercents[i] = new BigDecimal((double) 100 * votersForCandidates[i] / votersCount).setScale(2, RoundingMode.HALF_UP).doubleValue(); } for (int i = 0; i < candidateCount; i++) { out.printf("%.2f%%%n", votersPercents[i]); } out.flush(); } } Because of the Memory limit: which no more than 64 MB. votersPercents array is useless and should be removed. But the main error is you reading candidateCount in the wrong way. str.substring(0, 1) - how many digits can you read? What max candidateCount is? You use Scanner class. It has method nextInt() - you can just use it, you don't need to read strings and split them into numbers manually. 42 8 2 4 6 13 14 14 19 26 26 30 60 89 89 89 89 90 90 90 90 90 91 91 93 94 94 94 94 94 94 94 95 95 95 96 96 97 98 98 98 99 100 100 184 186 209 402 408 488 621 622 Are you sure? It get 0 nanoseconds for mine TLE67 version (for any random permutation of input). Edited by author 06.03.2020 00:50 Yes, I am sure. The tests are a bit peculiar for this problem. Some group of tests target specific solutions, so it's entirely possible your solution deals with some of the last tests easily (there should be 81 of them), but fails on earlier ones. Edited by author 05.03.2020 18:15 Thank you for the information. $ Before going to the solution, make sure that you had tried enough, please. $ Code:- #include<bits/stdc++.h> #define START int main(){ #define END system("PAUSE");return 0;} using namespace std; START int n, guest=2; cin >> n; guest += n; while(n--) { string s; cin >> s; for(int i=0; i<s.size(); i++) { if(s[i]=='+') { guest++; } } } if(guest != 13) { cout << 100*guest << endl; } else { cout << 100*(guest+1) << endl; } END ///Thank You and Pray for me. Edited by author 05.03.2020 17:01 It's mean you are checking condition if variable N = 45 or N = 5,6,7,8 then go to do statement below your condition N = 45 -> answer = 2269806340 N = 5 -> answer = 10 N = 6 -> answer = 16 N = 7 -> answer = 26 N = 8 -> answer = 42 I've used BST but still cannot optimize it... similar code on C is accepted with 0.171s 300kb but Python is processing the code way longer and TLE #14. And no solutions on python so far. Is there something that can be done? The minimal output is: 1-2*5 = -9. Edited by author 04.03.2020 22:45 consider follow string: ABZZBBBZZA. 2 polindroms: ZZBBBZZ and ABA - correctly for this problem? i think answer is 3 polindroms: AB ZZBBBZZ A I thin its 4 palindromes A B ZZBBBZZ A Смотрю с любовью на свои более 10-летней давности попытки решать задачи. Спасибо, ACM.Timus! |
|