답안 #95562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95562 2019-02-02T05:29:17 Z oolimry Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1350 ms 144868 KB
#include <bits/stdc++.h>
using namespace std;
inline int readInt() {
    int x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') ch = getchar();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar();
	}
    return x;
}


int X[10000000], Y[10000000];
bool in(int a, int b){
    /// if b is under a, return true
    int x1 = X[a];
    int x2 = X[b];
    int y1 = Y[a];
    int y2 = Y[b];
    return abs(x1 - x2) <= y1 - y2;
}
int main(){
    //freopen("i.txt.txt","r",stdin);
	int n = readInt();
	for(int i = 0; i < n; i++) {
		X[i] = readInt();
		Y[i] = readInt();
		// write code here
	}
	// write code here
	//for(int i  = 0;i < n;i++){
        //printf("%d %d\n",X[i],Y[i]);
	//}

	stack<int> s;

	if(in(2,3)){
        //printf("yes");
	}
	for(int i = 0;i < n;i++){
        if(s.empty()){
            s.push(i);
            continue;
        }

        else if(in(s.top(),i)){
            continue;
        }

        else if(in(i,s.top())){
            while(!s.empty() && in(i,s.top())){
                s.pop();
            }
            s.push(i);
        }

        else{
            s.push(i);
        }
	}

	printf("%d",s.size());
	return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:64:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d",s.size());
              ~~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 959 ms 142884 KB Output is correct
2 Correct 953 ms 144868 KB Output is correct
3 Correct 944 ms 140412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 31 ms 5240 KB Output is correct
15 Correct 28 ms 5112 KB Output is correct
16 Correct 26 ms 4884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 838 ms 124968 KB Output is correct
2 Correct 866 ms 127548 KB Output is correct
3 Correct 844 ms 124208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 959 ms 142884 KB Output is correct
2 Correct 953 ms 144868 KB Output is correct
3 Correct 944 ms 140412 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 31 ms 5240 KB Output is correct
18 Correct 28 ms 5112 KB Output is correct
19 Correct 26 ms 4884 KB Output is correct
20 Correct 838 ms 124968 KB Output is correct
21 Correct 866 ms 127548 KB Output is correct
22 Correct 844 ms 124208 KB Output is correct
23 Correct 1350 ms 120276 KB Output is correct
24 Correct 1225 ms 115304 KB Output is correct
25 Correct 1123 ms 110384 KB Output is correct