답안 #971732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971732 2024-04-29T08:22:02 Z Halym2007 Jakarta Skyscrapers (APIO15_skyscraper) C++17
10 / 100
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
const int N = 3e4 + 5;
pair <int, int> p[N];

int n, m;

int main () {
//	freopen ("input.txt", "r", stdin);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> p[i].ff >> p[i].ss;
	}
//	cout << "men";
//	return 0;
	if (m == 2) {
		int x = abs (p[0].ff  - p[1].ff);
		if (x % p[0].ss) {
			cout << "-1\n";
		}
		else {
			cout << x / p[0].ss << "\n";
		}
	}
	else {
//		return 0;
		int x = abs (p[0].ff - p[1].ff);
		int jogap = 1e9;
		if (x % p[0].ss == 0) jogap = x / p[0].ss;
//		cout << "men";
		int a1 = abs (p[2].ff - p[0].ff);
		int a2 = abs (p[2].ff - p[1].ff);
		if ((a1 % p[0].ss == 0) and (a2 % p[2].ss == 0)) {
			jogap = min (jogap, a1 / p[0].ss + a2 / p[2].ss);
		}
		if (jogap == 1e9) jogap = -1;
		cout << jogap << "\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -