답안 #56922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56922 2018-07-13T07:57:32 Z 정원준(#1637) 방벽 (JOI15_walls) C++11
10 / 100
3000 ms 4592 KB
#include <bits/stdc++.h>
#define L long long

using namespace std;

L s[200020],e[200020];
vector<L>attack;
L at[200020];
L ans[200020];
L n,m;

int main()
{
	scanf("%lld %lld",&n,&m);
	L i,j;
	for(i=1;i<=n;i++)
	{
		scanf("%lld %lld",&s[i],&e[i]);
	}
	for(i=1;i<=m;i++)
	{
		scanf("%lld",&at[i]);
	}
	for(i=1;i<=m;i++)
	{
		if(attack.size()>0&&i<m&&(at[i]-attack[attack.size()-1])*(at[i]-at[i+1])<=0) continue;
		attack.push_back(at[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;j<attack.size();j++)
		{
			if(attack[j]>e[i])
			{
				L sub=attack[j]-e[i];
				ans[i]+=sub;
				s[i]+=sub;
				e[i]+=sub;
			}
			if(attack[j]<s[i])
			{
				L sub=s[i]-attack[j];
				ans[i]+=sub;
				s[i]-=sub;
				e[i]-=sub;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		printf("%lld\n",ans[i]);
	}
}

Compilation message

walls.cpp: In function 'int main()':
walls.cpp:31:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<attack.size();j++)
           ~^~~~~~~~~~~~~~
walls.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~
walls.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&s[i],&e[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
walls.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&at[i]);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 49 ms 4180 KB Output is correct
3 Correct 56 ms 4256 KB Output is correct
4 Correct 61 ms 4468 KB Output is correct
5 Correct 52 ms 4468 KB Output is correct
6 Correct 51 ms 4468 KB Output is correct
7 Correct 40 ms 4468 KB Output is correct
8 Correct 63 ms 4468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1476 ms 4468 KB Output is correct
2 Execution timed out 3067 ms 4592 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 49 ms 4180 KB Output is correct
3 Correct 56 ms 4256 KB Output is correct
4 Correct 61 ms 4468 KB Output is correct
5 Correct 52 ms 4468 KB Output is correct
6 Correct 51 ms 4468 KB Output is correct
7 Correct 40 ms 4468 KB Output is correct
8 Correct 63 ms 4468 KB Output is correct
9 Correct 1476 ms 4468 KB Output is correct
10 Execution timed out 3067 ms 4592 KB Time limit exceeded
11 Halted 0 ms 0 KB -