Submission #121096

# Submission time Handle Problem Language Result Execution time Memory
121096 2019-06-26T06:06:19 Z 윤지학(#2973) Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 384 KB
#pragma GCC optimize("O3")
#pragma GCC target("arch=skylake")
#include <cstdio>

int n;
int d[100001][2];

int main() {
	long long s = 0;
	int i, j, k, l, m, x, y;
	scanf("%d", &n);
	for (i = 0; i < n + n; i++) {
		scanf("%d%d", &x, &y);
		if (x < 1) {
			s += 1 - x;
			x = 1;
		}
		if (x > n) {
			s += x - n;
			x = n;
		}
		if (y < 1) {
			s += 1 - y;
			y = 1;
		}
		if (y > 2) {
			s += y - 2;
			y = 2;
		}
		d[x - 1][y - 1]++;
	}
	x = y = 0;
	for (i = 0; i < n; i++) {
		x += d[i][0] - 1;
		y += d[i][1] - 1;
		while (x > 0 && y < 0) {
			s++;
			x--;
			y++;
		}
		while (x < 0 && y > 0) {
			s++;
			x++;
			y--;
		}
	}
	printf("%lld\n", s);
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:10:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j, k, l, m, x, y;
         ^
joi2019_ho_t4.cpp:10:12: warning: unused variable 'k' [-Wunused-variable]
  int i, j, k, l, m, x, y;
            ^
joi2019_ho_t4.cpp:10:15: warning: unused variable 'l' [-Wunused-variable]
  int i, j, k, l, m, x, y;
               ^
joi2019_ho_t4.cpp:10:18: warning: unused variable 'm' [-Wunused-variable]
  int i, j, k, l, m, x, y;
                  ^
joi2019_ho_t4.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -