답안 #971721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971721 2024-04-29T08:15:42 Z Halym2007 Jakarta Skyscrapers (APIO15_skyscraper) C++17
0 / 100
1 ms 348 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 {
		int x = abs (p[0].ff - p[1].ff);
		int jogap = 1e9;
		if (x % p[0].ss == 0) jogap = x / p[0].ff;
//		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 1 ms 348 KB Output is correct
3 Runtime error 1 ms 348 KB Execution killed with signal 8
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 348 KB Execution killed with signal 8
4 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 Runtime error 1 ms 348 KB Execution killed with signal 8
4 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 Runtime error 1 ms 348 KB Execution killed with signal 8
4 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 Runtime error 1 ms 348 KB Execution killed with signal 8
4 Halted 0 ms 0 KB -