답안 #484843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484843 2021-11-05T15:42:49 Z luka1234 Gift (IZhO18_nicegift) C++14
0 / 100
757 ms 36016 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
ll n,m;
ll a[1000001];
ll sum=0;
int main(){
	cin>>n>>m;
	for(ll k=1;k<=n;k++){
		cin>>a[k];
		sum+=a[k];
	}
	if(sum%m!=0){
		cout<<-1;
		return 0;
	}
	ll bolo=a[1];
	if(bolo>(sum/m)){
		cout<<-1;
		return 0;
	}
	ll A=a[1];
	ll N=n;
	ll x=__gcd(A,m);
	ll y=m/x;
	ll das=A/x;
	for(ll k=1;k<=n;k+=y){
		cout<<das<<' ';
		if((k+m)<=n+1){
			for(ll i=k;i<k+m;i++){
				cout<<i<<' ';
			}
		}
		else{
			for(ll i=k;i<=n;i++){
				cout<<i<<' ';
			}
			ll raod=n-k+1;
			raod=m-raod;
			for(ll i=1;i<raod+1;i++){
				cout<<i<<' ';
			}
		}
		cout<<"\n";
	}
    return 0;
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:25:5: warning: unused variable 'N' [-Wunused-variable]
   25 |  ll N=n;
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 757 ms 36016 KB Expected int32, but "500000000000" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -