답안 #57160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57160 2018-07-14T07:31:21 Z 정원준(#1655) JOIRIS (JOI16_joiris) C++11
15 / 100
3 ms 592 KB
#include <bits/stdc++.h>
#define L long long

using namespace std;

L n,k;
L a[55];

vector<L>ans1,ans2;

int main()
{
	scanf("%lld %lld",&n,&k);
	L i,j,k;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=2;i<=n;i++)
	{
		while(a[i]<a[i-1])
		{
			ans1.push_back(1);
			ans2.push_back(i);
			a[i]+=2;
		}
	}
	for(i=2;i<=n;i++)
	{
		a[i]-=a[1];
	}
	a[1]=0;
	for(i=3;i<=n;i++)
	{
		while(a[i]>a[i-1])
		{
			for(j=i-2;j>=1;j-=2)
			{
				ans1.push_back(2);
				ans2.push_back(j);
				a[j]++;
				a[j+1]++;
				if(j==1)
				{
					for(k=1;k<=n;k++)
					{
						a[k]--;
					}
				}
			}
		/*puts("");
		for(k=1;k<=n;k++)
		{
			printf("%lld ",a[k]);
		}
		puts("");*/
		}
	}
	for(i=1;i<=a[2]/2;i++)
	{
		ans1.push_back(1);
		ans2.push_back(1);
	}
	if(a[2]%2)
	{
		puts("-1");
		return 0;
	}
	printf("%lld\n",ans1.size());
	for(i=0;i<ans1.size();i++)
	{
		printf("%lld %lld\n",ans1[i],ans2[i]);
	}
}

Compilation message

joiris.cpp: In function 'int main()':
joiris.cpp:69:29: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'std::vector<long long int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%lld\n",ans1.size());
                  ~~~~~~~~~~~^
joiris.cpp:70:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<ans1.size();i++)
          ~^~~~~~~~~~~~
joiris.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~
joiris.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 3 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 3 ms 592 KB Output is correct
17 Incorrect 3 ms 592 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 3 ms 592 KB Output is correct
17 Incorrect 2 ms 592 KB Output isn't correct
18 Halted 0 ms 0 KB -