답안 #121081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121081 2019-06-26T05:14:58 Z 김세빈(#2968) Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll D[101010];
ll n, s, ans;

int main()
{
	ll i, x, y;

	scanf("%lld", &n);

	for(i=0; i<n+n; i++){
		scanf("%lld%lld", &x, &y);
		if(x < 1) ans += 1 - x, x = 1;
		if(x > n) ans += x - n, x = n;
		if(y < 1) ans += 1 - y, y = 1;
		if(y > 2) ans += y - 2, y = 2;
		D[x] ++;
		if(y == 1) s ++;
	}

	for(i=1; i<=n; i++){
		D[i] += D[i - 1];
		ans += abs(2 * i - D[i]);
	}

	printf("%lld\n", ans + abs(n - s));

	return 0;
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
joi2019_ho_t4.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -