| Show all threads Hide all threads Show all messages Hide all messages |
| help c++ | Barbs | 1910. Titan Ruins: Hidden Entrance | 10 Jun 2019 17:22 | 4 |
#include <iostream> using namespace std; int main() { int a[1000]; int n=0,s,sx=0,m=0; cin >> n; for(int i=0;i<n;i++){ cin >> a[i]; } for(int u=1;u<n-1;u++){ s=a[u]+a[u+1]+a[u+2]; if(s>sx){ sx=s; m=u+1; }} if (n==3){ sx=a[0]+a[1]+a[2]; m=2; } cout << sx << " " << m << endl; } #include<iostream> using namespace std; int main() { int numSection; cin >> numSection; int a[numSection]; for (int i = 0; i < numSection; i++) { cin >> a[i]; } int n = numSection - 3 + 1; int max = 0; int middleNumSec = 0; for (int i = 0; i < n; i++) { if (i + 3 > numSection) { break; } int sum = 0; for (int j = i; j < i + 3; j++) { sum += a[j]; } if (sum > max) { max = sum; middleNumSec = i + 2; } } cout << max << " " << middleNumSec << endl;
system("pause"); return 0; } My solution: #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; int a[maxn]; int sum,ans; int cnt; main(){ scanf("%d",&n); for(int i=1; i <= n; i++){ scanf("%d",&a[i]); } for(int i=1; i <= n-2; i++){ sum=a[i]+a[i+1]+a[i+2]; if(ans < sum){ ans=sum; cnt=i+1; } } printf("%d %d",ans,cnt);
return 0; } OMG man, thank u) this is correctly #include <iostream> using namespace std; int a[1000], n = 0, s, sx = 0, m = 0; void main() {
cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int u = 0; u < n; u++) { s = a[u] + a[u + 1] + a[u + 2]; if (s > sx) { sx = s; m = u + 2; } } |
| not clear statements | Ivan Lakhtin`~ | 1738. Computer Security | 9 Jun 2019 19:00 | 1 |
For those who as I has wa3 or wa5 and don't understand why: 1) similar must be personal number, not passwords 2) personal number is decimal number 3) to get other password (i.e. calculate diffeence of passwords) we can ONLY change digit, we can't insert or erase digits like in personal number May be you don't have theese mistakes, but I spent a day to undestand it |
| ъеъ | vtalgo19_NChernyshev☭ | 1000. A+B Problem | 8 Jun 2019 03:21 | 1 |
ъеъ vtalgo19_NChernyshev☭ 8 Jun 2019 03:21 |
| Solution Hint | Shibly | 1740. Deer is Better! | 6 Jun 2019 14:00 | 1 |
Speed is not constant. It can be 0 or infinity. But it covers each k kilometers in h hours. So, for a segment of length less than k, minimum time is 0 and maximum time is h. Edited by author 06.06.2019 14:01 |
| TLE #62 | Oracle[Lviv NU] | 1589. Sokoban | 6 Jun 2019 05:54 | 5 |
TLE #62 Oracle[Lviv NU] 3 Nov 2009 20:40 Can somebody give me some hard test - my program works fine on all tests, which I can think out. BTW, here is some of them: ######## #.OOOOO# #$O$O$O# #OO$O$O# #@O$O$O# ###***O# #......# ######## ######## #.O$OO.# #O$..$O# #$$..$O# #O$..$$# #@$O.$O# #..$OO.# ######## ######## #.O$OO.# #O$..$O# #$$..$O# #O$..$$# #@$..$O# #.O$OO.# ######## ######## #......# ###***O# #@O$O$O# #OO$O$O# #$O$O$O# #.OOOOO# ######## ######## #.....O# #$$$$$O# #OO...O# #$$$$$O# #O.OO$.# #.O$.$+# ######## ######## #......# ###***O# #@O$O$O# #OO$O$O# #OO$O$O# #OOOOOO# ######## ######## #.$.$OO# #@OOOOO# #O$$$$$# #O.....# #$$$$$$# #......# ######## ######## #.OOO.O# #@$O##O# #OOO*OO# #.$O$O$# #$$$$..# #...OOO# ######## ######## #OOOO.O# #@OO##O# #OOO*OO# #.$O$OO# #$$$$.O# #...OOO# ######## ####### #@$OO.# #$O$OO# #.O.OO# ####### P.S. space I've changed to O. Edited by author 03.11.2009 20:42 I have TLE 62 too. Don't have ideas of how to proceed. Can you give a hint of how you have improved you program to pass this test? I've stored only those positions, which can not be processed in some steps by greedy algo + store only positions, where man is in lowest-left cell + stop, when position is surely bad (I've used a lot of classes of bad positions) + make moves, that is surely necessary. Hi Oracle, can u give us some cases that considered as a bad position? I have a prunning issue also on my solution |
| Почему ваш компилятор не видит директиву "stdafx.h" | Ilya | 1000. A+B Problem | 5 Jun 2019 15:50 | 2 |
#include "stdafx.h" #include <iostream> int main() { int a; int b; int c; scanf_s("%d%d\n", &a, &b); c = a + b; printf("%d\n", c); return 0; } Зачем тебе эти директивы вообще? Нужна только айострим. И пишется так: <stdafx.р> |
| Всё оч просто.с++ | jabajaba | 1000. A+B Problem | 5 Jun 2019 15:47 | 1 |
#include <iostream> using namespace std; int main() { long long a, b; cin >> a >> b; cout << a+b; } |
| Any other suggestion? | adityarev | 1589. Sokoban | 5 Jun 2019 12:53 | 2 |
Hi guys, i've tried to solve this problem with A*. I came with pull distance as heuristic and calculate the distance table with Floyd's algorithm. I also have put deadlock detector (for Simple and Frozen) on my code. Is there something i miss? Or do you have any other suggestion? I am very happy if i can discuss with you guys. Thanks before for your help :) I know some interesting optimisations which helped me get TLE 78 but I don't understand how to use A* in this problem. Let's discuss it. My email is imoskovchenko72@gmail.com |
| for those ,who don't know what to do with WA 7,8; | LaVuna [KHNURE] | 1131. Copying | 4 Jun 2019 22:49 | 1 |
I tried to pick up to my occasion all data types ,but there was some problem ;Then i tried using data type "auto" and it's worked! |
| What's test#19 ? anything must notice? | Fate | 1332. Genie Bomber | 4 Jun 2019 11:08 | 6 |
I got WA#19 too! Any tricky test here? test 19 is like this 2 1 1 101 101 2 1 Your answer is probably 0 The right one is 1 Thank you, that was really helpful! |
| Thanks for such a cool problem | Md sabbir Rahman | 2124. Algebra on Segment | 4 Jun 2019 07:06 | 1 |
Whoever made this problem, thanks a lot! Seeing group theory applied in cp felt pretty cool. Alos learnt a lot thanks to this problem |
| Precision errors? | Timothy Mou | 2121. Intersection of Parabolas | 3 Jun 2019 20:29 | 3 |
I believe I am having precision errors when calculating the solution. I changed from doubles to long doubles and got one more test case, so I believe my solution is correct but not precise enough. Any tips to resolve this? Never mind, there was simplification in the calculations and then I just hard-coded printed out the decimals. This problem is just cancer Yes Some tests: a = 1 ans = 3.666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667 a = 1.5 ans = 5.666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667 a = 666 ans = 2663.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666674 a = 1000000000000000000 ans = 3999999999999999999.666666666666666666666666666666666666666666666666666666666666666333333333 Edited by author 03.06.2019 20:30 |
| wa16 (+) | exwRabbits_AlMag(VNTU) | 1701. Ostap and Partners | 2 Jun 2019 20:02 | 4 |
wa16 (+) exwRabbits_AlMag(VNTU) 3 Jun 2009 20:34 have no ideas. i've runned my random test generator and my program passed over 1000 tests, but wa. help, please. Re: wa16 (+) Nikita Glashenko [Samara SAU] 19 Jul 2009 00:59 This hand-made test helped me with WA#16: 5 3 1 2 -2 4 3 2 4 2 -1 The possible answer is: Possible 0 1 3 0 2 Good luck. Глащенко Никита, thank you very much! Really useful test! |
| Crash (access violation) test #17 | alex270295 | 1837. Isenbaev's Number | 30 May 2019 08:47 | 8 |
can anybody help me with this problem? can somebody tell what kind of test is it i have already checked. all right. maximum number of participants is 300. [code deleted] Edited by moderator 19.11.2019 23:09 Maybe you found the error, but i got stuck on this problem and tried your solution. I hoped to find the problem of my submission. When there are 300 different names without Isenbaev, your program added Isenbaev with number 301 and crashes because of the array index > 300 setting array to [1..301] did the trick and AC thank you! your reply help me a lot! thank you, you saved my day |
| If you have WA2 | Andrew Sboev [USU] | 1010. Discrete Function | 27 May 2019 21:32 | 7 |
1) Maybe, you are reading long long variable with this command : scanf("%d",&arr[i]); It is not right. You should do, for example, it with next command scanf("%I64d",&arr[i]); 2) Maybe, you were confused by statement. You have to choose such two points so line that passing through this points has maximal absolute value of inclination, not just inclination. 3) Maybe, you are doing something like this : for ( int i = 1 ; i <= n ; ++i ) { long long d = abs2(arr[i+1] - arr[i]); if ( d > x ) { x = d; m1 = i; } } There is a mistake in first line. Right way is for ( int i = 1 ; i < n ; ++i ) { It was my biggest mistake, because the problem itself is so simple. Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thanks a lot! The definition of inclination is ambiguous in the problem statement. Thanks a lot! I have ignored "absolute value" too. Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! |
| Statement is incomplete? | mouse_wireless2 | 1382. Game with Cards | 23 May 2019 17:45 | 1 |
Problem statement says "His friends write numbers from 1 to N on cards", but it doesn't mention that these numbers should be distinct. Yet, it seems like the problem only accepts solutions in which the numbers are distinct (i.e. the numbers on the N cards are a permutation of [1..N]). |
| Running the java applet | Whyyes | 1365. Testing Calculator | 23 May 2019 02:31 | 2 |
Since you're able to download it, you can actually decompile it and submit the code to get accepted. There's a Thread.Sleep(3000) in there that you'll need to comment out. |
| To admins: Wrong answer getting accepted | basuki | 1576. Telephone Tariffs | 22 May 2019 17:52 | 1 |
The cases when all times are less than 6 seconds are neglected. So the cost of each plan should be zero as all calling will be free but adding the basic plan to the cost leads to AC. |
| В чем проблема такого решения на ruby? | ypavlov | 1000. A+B Problem | 22 May 2019 11:41 | 1 |
puts gets.split(' ').sum { |s| s.to_i } а вот так ок: puts gets.split(' ').map { |s| s.to_i }.inject(0) {|sum,x| sum + x } что не так с с sum? Edited by author 22.05.2019 11:43 Edited by author 29.05.2019 02:44 |
| Any proof? | bsu.mmf.team | 2121. Intersection of Parabolas | 20 May 2019 18:15 | 1 |
|