Submission #30467499
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N, K;
cin >> N >> K;
int a[N][2], chk[N], now[N], know[N];
for (int i = 0; i < N; i++) cin >> a[i][0];
for (int i = 0; i < N; i++) cin >> a[i][1];
for (int i = 0; i < N; i++) chk[i]=0;
for (int i = 0; i < N; i++) know[i]=0;
for (int i = 0; i < N; i++) now[i]=a[i][chk[i]];
for (int i = 0; i < N-1; i++)
{
/*for (int j = 0; j < N; j++)
{
cout << now[j] << " ";
}
for (int j = 0; j < N; j++)
{
cout << know[j] << " ";
}
cout << "\n";*/
if (abs(now[i]-a[i+1][0]) > K && abs(now[i]-a[i+1][1]) > K)
{
int k = 1;
for (int j = i; j >= 0; j--)
{
if (know[j] == 0)
{
k=0;
i = j-1;
know[j]=1;
for (int k=j+1; k<N-1; k++) know[k] = 0;
chk[j] = !chk[j];
now[j] = a[j][chk[j]];
break;
}
}
if(k)
{
cout << "No\n";
exit(0);
}
}
}
cout << "Yes\n";
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Choose Elements |
| User | Popochang |
| Language | C++ (GCC 9.2.1) |
| Score | 0 |
| Code Size | 967 Byte |
| Status | WA |
| Exec Time | 2205 ms |
| Memory | 7516 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
| 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, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt, example2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | WA | 36 ms | 3940 KiB |
| 001.txt | WA | 2 ms | 3508 KiB |
| 002.txt | WA | 36 ms | 3924 KiB |
| 003.txt | AC | 2 ms | 3512 KiB |
| 004.txt | AC | 2 ms | 3396 KiB |
| 005.txt | AC | 2 ms | 3432 KiB |
| 006.txt | AC | 111 ms | 7388 KiB |
| 007.txt | TLE | 2205 ms | 6956 KiB |
| 008.txt | AC | 86 ms | 6340 KiB |
| 009.txt | TLE | 2205 ms | 6140 KiB |
| 010.txt | AC | 114 ms | 7340 KiB |
| 011.txt | TLE | 2205 ms | 7092 KiB |
| 012.txt | AC | 115 ms | 7416 KiB |
| 013.txt | TLE | 2205 ms | 7208 KiB |
| 014.txt | AC | 118 ms | 7516 KiB |
| 015.txt | TLE | 2205 ms | 7212 KiB |
| 016.txt | AC | 115 ms | 7396 KiB |
| 017.txt | TLE | 2205 ms | 7280 KiB |
| 018.txt | AC | 98 ms | 6908 KiB |
| 019.txt | TLE | 2205 ms | 5524 KiB |
| 020.txt | AC | 113 ms | 7300 KiB |
| 021.txt | TLE | 2205 ms | 7092 KiB |
| 022.txt | AC | 112 ms | 7420 KiB |
| 023.txt | AC | 113 ms | 7460 KiB |
| example0.txt | AC | 3 ms | 3396 KiB |
| example1.txt | AC | 3 ms | 3512 KiB |
| example2.txt | AC | 2 ms | 3392 KiB |