-
Notifications
You must be signed in to change notification settings - Fork 4
/
sign.cpp
54 lines (44 loc) · 940 Bytes
/
sign.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
const int N = 2e5 + 11;
void solve() {
int n,diff;
cin>>n>>diff;
vector<bool> sign;
vector<int> index;
vector<int> val;
int li[n];
for (int i = 0; i < n; i++)
cin>>li[i];
int target = 0;
for (int i = 1; i < n; i++) {
target = li[i-1]+diff;
if(target==li[i]) continue;
sign.push_back(target>li[i]);
index.push_back(i+1);
val.push_back(abs(target-li[i]));
li[i]=target;
}
cout<<sign.size()<<endl;
for (int i = 0; i < sign.size(); i++) {
cout<<(sign[i]?'+':'-')<<" ";
cout<<index[i]<<" ";
cout<<val[i]<<endl;
}
}
int main() {
freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int no_of_test_cases = 1;
// cin >> no_of_test_cases;
while (no_of_test_cases--)solve();
return 0;
}