# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
351911 |
2021-01-20T09:32:05 Z |
YJU |
JOIRIS (JOI16_joiris) |
C++14 |
|
1 ms |
512 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=2e5+5;
const ld pi=acos(-1);
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll n,k,a[N],b[N],l[N];
vector<pll> ans;
void out(){
//REP(i,n)cout<<a[i]<<(i==n-1?"\n":" ");
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>k;
REP(i,n){
cin>>a[i];
b[i%k]+=a[i];
}
REP(i,n%k){
if(b[i]%k!=b[0]%k){
cout<<"-1\n";return 0;
}
}
for(int i=n%k;i<k;i++){
if(b[i]%k!=b[k-1]%k){
cout<<"-1\n";return 0;
}
}
for(int i=1;i<n;i++)while(a[i]<a[i-1])a[i]+=k,ans.pb(mp(1,i+1));
for(int i=0;i<n-1;i++){
for(int j=a[i];j<a[i+1];j++){
for(int jj=i-k-1;jj>=0;jj--){
ans.pb(mp(2,jj+1));
}
if(i%k!=k-1)--l[i%k];
}
}
for(int i=k-3;i>=0;i--)l[i]+=l[i+1];
REP(i,n){
while(l[i]<0){
ans.pb(mp(1,i+1));
l[i]+=k;
}
}
if(n%k>=1&&l[0]<l[k-1]){
for(int i=0;i<n%k;i++)l[i]+=k,ans.pb(mp(1,i+1));
}
if(n%k>=1){
for(int i=n-k;i>=0;i-=k){
for(int j=0;j<l[0]-l[k-1];j++)ans.pb(mp(2,i+1));
}
}
cout<<SZ(ans)<<"\n";
for(auto i:ans)cout<<i.X<<" "<<i.Y<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |