Submission #573244

# Submission time Handle Problem Language Result Execution time Memory
573244 2022-06-06T09:47:48 Z guugiuh Lightning Rod (NOI18_lightningrod) C++14
100 / 100
841 ms 262144 KB
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
typedef vector<int> vi;
inline int readInt() {
    int x = 0;
    char ch = getchar_unlocked();
    while (ch < '0' || ch > '9') ch = getchar_unlocked();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
    return x;
}
 
int MinPyramids(int N, vi X, vi Y) 
{ 
    int res = 0; 
    vi T1(N + 1), T2(N + 1); 
    for (int i = 0; i < N; i++) 
        T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i]; 
    for (int i = 0; i < N; i++) 
        if (i + (i & -i) <= N) 
            T1[i + (i & -i)] = min(T1[i + (i & -i)], T1[i]), T2[i + (i & -i)] = max(T2[i + (i & -i)], T2[i]); 
    for (int i = 0; i < N; i++) 
    { 
        int mn = 2e9+1, mx = -mn; 
        for (int j = N - i - 1; j > 0; j -= j & -j) 
            mn = min(mn, T1[j]); 
        for (int j = i; j > 0; j -= j & -j) 
            mx = max(mx, T2[j]); 
        if (mx < X[i] + Y[i] && mn > X[i] - Y[i]) 
            res++; 
    } 
    return res; 
}
 
int main(){
	int N = readInt();
	vector <int> X(N);
	vector <int> Y(N);
	for(int i = 0; i < N; i++) {
		X[i] = readInt();
		Y[i] = readInt();
	}
	int ans= MinPyramids(N,X,Y);
	printf("%d", ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 615 ms 228812 KB Output is correct
2 Correct 638 ms 228052 KB Output is correct
3 Correct 665 ms 221744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 19 ms 8128 KB Output is correct
15 Correct 17 ms 8200 KB Output is correct
16 Correct 16 ms 7364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 653 ms 234904 KB Output is correct
2 Correct 665 ms 262144 KB Output is correct
3 Correct 659 ms 255260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 615 ms 228812 KB Output is correct
2 Correct 638 ms 228052 KB Output is correct
3 Correct 665 ms 221744 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 19 ms 8128 KB Output is correct
18 Correct 17 ms 8200 KB Output is correct
19 Correct 16 ms 7364 KB Output is correct
20 Correct 653 ms 234904 KB Output is correct
21 Correct 665 ms 262144 KB Output is correct
22 Correct 659 ms 255260 KB Output is correct
23 Correct 841 ms 262144 KB Output is correct
24 Correct 802 ms 262144 KB Output is correct
25 Correct 748 ms 262144 KB Output is correct