Submission #66491111
Source Code Expand
Copy
#include <stdio.h>#include <inttypes.h>int N;int P[312345];int combo_cnt[312345];int main(void) {int i;int num_combo, combo_start;uint64_t ans = 0;if (scanf("%d", &N) != 1) return 1;for (i = 0; i < N; i++) {if (scanf("%d" ,&P[i]) != 1) return 1;}num_combo = 0;combo_start = 0;for (i = 2; i < N; i++) {if ((P[i - 2] < P[i - 1]) != (P[i - 1] < P[i])) {combo_cnt[num_combo++] = i - 1 - combo_start;
#include <stdio.h> #include <inttypes.h> int N; int P[312345]; int combo_cnt[312345]; int main(void) { int i; int num_combo, combo_start; uint64_t ans = 0; if (scanf("%d", &N) != 1) return 1; for (i = 0; i < N; i++) { if (scanf("%d" ,&P[i]) != 1) return 1; } num_combo = 0; combo_start = 0; for (i = 2; i < N; i++) { if ((P[i - 2] < P[i - 1]) != (P[i - 1] < P[i])) { combo_cnt[num_combo++] = i - 1 - combo_start; combo_start = i - 1; } } combo_cnt[num_combo++] = N - 1 - combo_start; for (i = 2 + (P[0] > P[1]); i < num_combo; i += 2) { ans += (uint64_t)combo_cnt[i - 2] * combo_cnt[i]; } printf("%" PRIu64 "\n", ans); return 0; } /* 数の関係 < < < > > > > > < < < ----- A --------- B ----- C Aから1個以上、B全部、Cから1個以上 A_1 < A_2 に注意 */
Submission Info
Submission Time | |
---|---|
Task | C - ~ |
User | mikecat |
Language | C (gcc 12.2.0) |
Score | 350 |
Code Size | 887 Byte |
Status | AC |
Exec Time | 27 ms |
Memory | 4076 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 350 / 350 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt |
All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 1752 KiB |
sample01.txt | AC | 1 ms | 1640 KiB |
sample02.txt | AC | 1 ms | 1764 KiB |
testcase00.txt | AC | 6 ms | 2008 KiB |
testcase01.txt | AC | 27 ms | 3396 KiB |
testcase02.txt | AC | 4 ms | 1952 KiB |
testcase03.txt | AC | 27 ms | 3400 KiB |
testcase04.txt | AC | 22 ms | 3216 KiB |
testcase05.txt | AC | 27 ms | 3500 KiB |
testcase06.txt | AC | 18 ms | 2836 KiB |
testcase07.txt | AC | 27 ms | 3404 KiB |
testcase08.txt | AC | 0 ms | 1588 KiB |
testcase09.txt | AC | 0 ms | 1732 KiB |
testcase10.txt | AC | 8 ms | 2304 KiB |
testcase11.txt | AC | 25 ms | 4004 KiB |
testcase12.txt | AC | 18 ms | 3248 KiB |
testcase13.txt | AC | 27 ms | 4076 KiB |
testcase14.txt | AC | 19 ms | 2800 KiB |
testcase15.txt | AC | 10 ms | 2204 KiB |
testcase16.txt | AC | 18 ms | 2760 KiB |
testcase17.txt | AC | 8 ms | 2120 KiB |
testcase18.txt | AC | 18 ms | 2888 KiB |
testcase19.txt | AC | 5 ms | 1896 KiB |
testcase20.txt | AC | 18 ms | 2904 KiB |
testcase21.txt | AC | 7 ms | 2220 KiB |
testcase22.txt | AC | 19 ms | 2812 KiB |
testcase23.txt | AC | 11 ms | 2308 KiB |
testcase24.txt | AC | 19 ms | 2900 KiB |
testcase25.txt | AC | 10 ms | 2196 KiB |
testcase26.txt | AC | 19 ms | 2804 KiB |
testcase27.txt | AC | 5 ms | 1900 KiB |
testcase28.txt | AC | 19 ms | 2824 KiB |
testcase29.txt | AC | 8 ms | 2100 KiB |
testcase30.txt | AC | 19 ms | 2824 KiB |
testcase31.txt | AC | 4 ms | 1968 KiB |
testcase32.txt | AC | 19 ms | 2940 KiB |
testcase33.txt | AC | 9 ms | 2152 KiB |
testcase34.txt | AC | 19 ms | 2932 KiB |