Submission #59910083
Source Code Expand
// Problem: A - Add and Swap
// URL: https://atcoder.jp/contests/arc187/tasks/arc187_a
// Writer: WRuperD
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mininf = 1e9 + 7;
#define int long long
#define pb emplace_back
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){if(x<0){x=~(x-1);putchar('-');}if(x>9)write(x/10);putchar(x%10+'0');}
#define put() putchar(' ')
#define endl puts("")
const int MAX = 1e3 + 10;
int a[MAX];
void solve(){
int n = read(), k = read();
for(int i = 1; i <= n; i++){
a[i] = read();
}
vector <int> ans;
int lst = -inf;
for(int i = 1; i <= n; i++){
int mk = -1, maxn = -inf;
for(int j = i; j <= n; j++){
int now = a[j] + max(0ll, (j - i) * k);
if(now >= lst and (mk == -1 or maxn >= now)){
maxn = now;
mk = j;
}
}
if(mk == -1){
puts("No");
return ;
}
// write(mk), endl;
for(int j = mk - 1; j >= i; j--){
ans.pb(j);
swap(a[j], a[j + 1]);
a[j] += k;
}
lst = a[i];
// write(i), endl;
}
puts("Yes");
write(ans.size()), endl;
for(int i = 0; i < ans.size(); i++) write(ans[i]), put();
endl;
}
signed main(){
int t = 1;
while(t--) solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Add and Swap |
| User | WRuperD |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1435 Byte |
| Status | WA |
| Exec Time | 1 ms |
| Memory | 3660 KiB |
Compile Error
Main.cpp: In function ‘void solve()’:
Main.cpp:51:26: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
51 | for(int i = 0; i < ans.size(); i++) write(ans[i]), put();
| ~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 600 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt, 02_handmade_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3396 KiB |
| 00_sample_02.txt | AC | 1 ms | 3492 KiB |
| 01_test_01.txt | WA | 1 ms | 3460 KiB |
| 01_test_02.txt | WA | 1 ms | 3476 KiB |
| 01_test_03.txt | WA | 1 ms | 3500 KiB |
| 01_test_04.txt | WA | 1 ms | 3468 KiB |
| 01_test_05.txt | WA | 1 ms | 3500 KiB |
| 01_test_06.txt | WA | 1 ms | 3504 KiB |
| 01_test_07.txt | WA | 1 ms | 3652 KiB |
| 01_test_08.txt | WA | 1 ms | 3452 KiB |
| 01_test_09.txt | WA | 1 ms | 3496 KiB |
| 01_test_10.txt | WA | 1 ms | 3656 KiB |
| 01_test_11.txt | WA | 1 ms | 3480 KiB |
| 01_test_12.txt | WA | 1 ms | 3448 KiB |
| 01_test_13.txt | WA | 1 ms | 3472 KiB |
| 01_test_14.txt | WA | 1 ms | 3472 KiB |
| 01_test_15.txt | WA | 1 ms | 3472 KiB |
| 01_test_16.txt | AC | 1 ms | 3572 KiB |
| 01_test_17.txt | AC | 1 ms | 3468 KiB |
| 01_test_18.txt | AC | 1 ms | 3468 KiB |
| 01_test_19.txt | AC | 1 ms | 3440 KiB |
| 01_test_20.txt | AC | 1 ms | 3464 KiB |
| 01_test_21.txt | AC | 1 ms | 3504 KiB |
| 01_test_22.txt | AC | 1 ms | 3460 KiB |
| 01_test_23.txt | AC | 1 ms | 3536 KiB |
| 01_test_24.txt | AC | 1 ms | 3660 KiB |
| 01_test_25.txt | AC | 1 ms | 3464 KiB |
| 01_test_26.txt | AC | 1 ms | 3464 KiB |
| 01_test_27.txt | AC | 1 ms | 3560 KiB |
| 01_test_28.txt | AC | 1 ms | 3488 KiB |
| 01_test_29.txt | AC | 1 ms | 3488 KiB |
| 01_test_30.txt | AC | 1 ms | 3456 KiB |
| 01_test_31.txt | AC | 1 ms | 3464 KiB |
| 01_test_32.txt | AC | 1 ms | 3560 KiB |
| 01_test_33.txt | AC | 1 ms | 3472 KiB |
| 01_test_34.txt | AC | 1 ms | 3488 KiB |
| 01_test_35.txt | AC | 1 ms | 3560 KiB |
| 01_test_36.txt | AC | 1 ms | 3440 KiB |
| 02_handmade_01.txt | WA | 1 ms | 3488 KiB |
| 02_handmade_02.txt | WA | 1 ms | 3492 KiB |
| 02_handmade_03.txt | WA | 1 ms | 3492 KiB |
| 02_handmade_04.txt | WA | 1 ms | 3648 KiB |
| 02_handmade_05.txt | WA | 1 ms | 3500 KiB |
| 02_handmade_06.txt | WA | 1 ms | 3648 KiB |
| 02_handmade_07.txt | WA | 1 ms | 3532 KiB |
| 02_handmade_08.txt | WA | 1 ms | 3432 KiB |
| 02_handmade_09.txt | WA | 1 ms | 3364 KiB |
| 02_handmade_10.txt | WA | 1 ms | 3372 KiB |