Submission #980066
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
long long p[40000];
long long a[40000], b[40000];
int main()
{
//freopen("data.txt", "r", stdin);
/*freopen("data.txt", "w", stdout);
puts("20000");
printf("%d %d ", 1, 20000);
for(int i = 2;i < 20000;++i)
printf("%d ", i);
return 0;*/
long long n;
scanf("%lld", &n);
for(long long i = 1; i <= n; ++i)
scanf("%lld", &p[i]);
for(long long i = 1; i <= n; ++i)
{
if(i == 1)
{
a[ p[i] ] = 0;
b[ p[i] ] = 0;
}
else
{
if(p[i] > p[i - 1])
{
a[ p[i] ] = a[ p[i - 1] ] + (p[i] - p[i - 1]) * 20000;
b[ p[i] ] = b[ p[i - 1] ] - (p[i] - p[i - 1]) * 19999;
}
else
{
a[ p[i] ] = a[ p[i - 1] ] - (p[i - 1] - p[i]) * 20000;
b[ p[i] ] = b[ p[i - 1] ] + (p[i - 1] - p[i]) * 19999;
}
}
}
long long t = 1000000000000ll;
for(long long i = 1;i <= n;++i)
t = min(t, min((a[i] - 1), (b[i] - 1)));
for(long long i = 1;i <= n;++i)
{
a[i] -= t;
b[i] -= t;
}
for(long long i = 1; i <= n; ++i)
{
if(i == 1)
printf("%lld", a[i]);
else
printf(" %lld", a[i]);
}
printf("\n");
for(long long i = 1; i <= n; ++i)
{
if(i == 1)
printf("%lld", b[i]);
else
printf(" %lld", b[i]);
}
printf("\n");
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Construct Sequences |
User |
Wonter |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1613 Byte |
Status |
WA |
Exec Time |
9 ms |
Memory |
1152 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &n);
^
./Main.cpp:18:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &p[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt, example2.txt |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
WA |
3 ms |
256 KB |
001.txt |
WA |
3 ms |
256 KB |
002.txt |
WA |
3 ms |
256 KB |
003.txt |
WA |
3 ms |
256 KB |
004.txt |
WA |
3 ms |
256 KB |
005.txt |
WA |
9 ms |
1024 KB |
006.txt |
WA |
4 ms |
384 KB |
007.txt |
WA |
8 ms |
1024 KB |
008.txt |
WA |
6 ms |
640 KB |
009.txt |
WA |
9 ms |
1024 KB |
010.txt |
WA |
9 ms |
1152 KB |
011.txt |
WA |
9 ms |
1152 KB |
012.txt |
WA |
9 ms |
1152 KB |
013.txt |
WA |
9 ms |
1152 KB |
014.txt |
WA |
9 ms |
1152 KB |
015.txt |
WA |
9 ms |
1152 KB |
016.txt |
WA |
9 ms |
1152 KB |
017.txt |
WA |
9 ms |
1152 KB |
018.txt |
WA |
9 ms |
1152 KB |
example0.txt |
AC |
2 ms |
256 KB |
example1.txt |
WA |
3 ms |
256 KB |
example2.txt |
WA |
3 ms |
256 KB |