Submission #756087

# Submission time Handle Problem Language Result Execution time Memory
756087 2023-06-11T05:28:07 Z SanguineChameleon Sails (IOI07_sails) C++17
40 / 100
1000 ms 1268 KB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

const int maxn = 1e5 + 20;
pair<int, int> a[maxn];
int cnt[maxn];

void just_do_it() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		sort(cnt + 1, cnt + a[i].first + 1, greater<int>());
		for (int j = a[i].first - a[i].second + 1; j <= a[i].first; j++) {
			cnt[j]++;
		}
	}
	long long res = 0;
	for (int i = 1; i <= a[n].first; i++) {
		res += 1LL * cnt[i] * (cnt[i] - 1) / 2;
	}
	cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 340 KB Output is correct
2 Correct 503 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 1236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 1180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 1268 KB Time limit exceeded
2 Halted 0 ms 0 KB -