| Task: | Zigzag |
| Sender: | 🍦🍧🍨 |
| Submission time: | 2015-09-16 17:54:15 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
| #3 | TIME LIMIT EXCEEDED | -- | details |
| #4 | TIME LIMIT EXCEEDED | -- | details |
| #5 | TIME LIMIT EXCEEDED | -- | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | TIME LIMIT EXCEEDED | -- | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
| #11 | TIME LIMIT EXCEEDED | -- | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
| #14 | TIME LIMIT EXCEEDED | -- | details |
| #15 | TIME LIMIT EXCEEDED | -- | details |
| #16 | TIME LIMIT EXCEEDED | -- | details |
| #17 | TIME LIMIT EXCEEDED | -- | details |
| #18 | TIME LIMIT EXCEEDED | -- | details |
| #19 | TIME LIMIT EXCEEDED | -- | details |
| #20 | TIME LIMIT EXCEEDED | -- | details |
| #21 | TIME LIMIT EXCEEDED | -- | details |
| #22 | TIME LIMIT EXCEEDED | -- | details |
| #23 | RUNTIME ERROR | 0.05 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:9:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
input/code.cpp:13:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &nums[i]);
^Code
#include <iostream>
using namespace std;
int main() {
cin.sync_with_stdio(false);
int n;
scanf("%d", &n);
int nums[n];
for (int i = 0; i < n; ++i)
{
scanf("%d", &nums[i]);
}
int max = 0;
int uplocalmax;
int downlocalmax;
int longest[n][2];
longest[n-1][0] = 1;
longest[n-1][1] = 1;
for (int i = n-2; i >= 0; i--)
{
uplocalmax = 1;
downlocalmax = 1;
for (int j = i+1; j < n; j++) {
if (nums[i] == nums[j]) {
if (longest[j][0] > uplocalmax) {
uplocalmax = longest[j][0];
}
if (longest[j][1] > downlocalmax) {
downlocalmax = longest[j][1];
}
}
else if (nums[i] < nums[j]) {
if ((longest[j][1]+1) > uplocalmax) {
uplocalmax = longest[j][1] + 1;
}
}
else {
if ((longest[j][0]+1) > downlocalmax) {
downlocalmax = longest[j][0] + 1;
}
}
}
longest[i][1] = downlocalmax;
longest[i][0] = uplocalmax;
if (downlocalmax > max)
{
max = downlocalmax;
}
if (uplocalmax > max)
{
max = uplocalmax;
}
}
printf("%d\n", max);
return max;
}Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 26914
209563339 493138663 352519700 ... |
| correct output |
|---|
| 17861 |
| user output |
|---|
| (empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 69623
448426297 297876050 307483466 ... |
| correct output |
|---|
| 46402 |
| user output |
|---|
| (empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 74436
633012861 731816315 697620472 ... |
| correct output |
|---|
| 49602 |
| user output |
|---|
| (empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40279
561990353 513856090 901866509 ... |
| correct output |
|---|
| 26955 |
| user output |
|---|
| (empty) |
Test 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 51496
683270487 631068160 190804676 ... |
| correct output |
|---|
| 34326 |
| user output |
|---|
| (empty) |
Test 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 97124
1000007 1000006 1000003 100000... |
| correct output |
|---|
| 61495 |
| user output |
|---|
| (empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 91945
1000005 1000005 1000006 100000... |
| correct output |
|---|
| 58521 |
| user output |
|---|
| (empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 96629
1000004 1000010 1000003 100001... |
| correct output |
|---|
| 61327 |
| user output |
|---|
| (empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 92161
1000042 1000001 1000055 100001... |
| correct output |
|---|
| 60962 |
| user output |
|---|
| (empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 96806
1000057 1000002 1000011 100006... |
| correct output |
|---|
| 64127 |
| user output |
|---|
| (empty) |
Test 11
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 99118
1000084 1000083 1000002 100008... |
| correct output |
|---|
| 66012 |
| user output |
|---|
| (empty) |
Test 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 98412
1000959 1000993 1000257 100064... |
| correct output |
|---|
| 65720 |
| user output |
|---|
| (empty) |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 90443
1000341 1000111 1000853 100021... |
| correct output |
|---|
| 60148 |
| user output |
|---|
| (empty) |
Test 14
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 94265
1000087 1000461 1000534 100020... |
| correct output |
|---|
| 62824 |
| user output |
|---|
| (empty) |
Test 15
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 91433
1001939 1009857 1000325 100505... |
| correct output |
|---|
| 60938 |
| user output |
|---|
| (empty) |
Test 16
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 96457
1005466 1001970 1000639 100288... |
| correct output |
|---|
| 64111 |
| user output |
|---|
| (empty) |
Test 17
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 91928
1003162 1008129 1007967 100683... |
| correct output |
|---|
| 61129 |
| user output |
|---|
| (empty) |
Test 18
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 96494
1076481 1008804 1047323 102583... |
| correct output |
|---|
| 64214 |
| user output |
|---|
| (empty) |
Test 19
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 98136
1025253 1017437 1050227 105377... |
| correct output |
|---|
| 65345 |
| user output |
|---|
| (empty) |
Test 20
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 90294
1098032 1037085 1089672 105311... |
| correct output |
|---|
| 60164 |
| user output |
|---|
| (empty) |
Test 21
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000
19836 85811 67650 86807 50191 ... |
| correct output |
|---|
| 66639 |
| user output |
|---|
| (empty) |
Test 22
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000
999999998 999999999 999999996 ... |
| correct output |
|---|
| 59975 |
| user output |
|---|
| (empty) |
Test 23
Verdict: RUNTIME ERROR
| input |
|---|
| 11
1000000000 1000000000 10000000... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
