답안 #224936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224936 2020-04-19T06:36:23 Z maximath_1 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
684 ms 227908 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gc getchar_unlocked
#define pc putchar_unlocked
int in(){
	char c=gc(); bool neg=false;
	for(; c<'0'||'9'<c; c=gc())
		if(c=='-') neg=true;
	int rs=c-'0'; c=gc();
	for(; '0'<=c && c<='9'; c=gc())
		rs=(rs<<1)+(rs<<3)+(c-'0');
	if(neg) rs=-rs;
	return rs;
}
void out(int _n){
	int N=_n, rev, count=0;
	rev=N;
	if(N==0) {pc('0'); return;}
	while((rev%10)==0) {count++; rev/=10;}
	rev=0;
	while(N!=0) {rev=(rev<<3)+(rev<<1)+N%10; N/=10;}
	while(rev!=0) {pc(rev%10+'0'); rev/=10;}
	while(count--) pc('0');
}
int pref[10000005], suff[10000005];
int n, x, y;
int main(){
	n=in();
	for(int i=0; i<n; i++){
		x=in(), y=in();
		pref[i]=x+y;
		suff[i]=y-x;
		if(i>0) pref[i]=max(pref[i], pref[i-1]);
	}
	int ans=0;
	for(int i=n-1; i>=0; i--){
		if((i==0||pref[i]>pref[i-1])
		 &&(i==n-1||suff[i]>suff[i+1]))
			ans++;
		if(i<n-1) suff[i]=max(suff[i], suff[i+1]);
	}
	out(ans); pc('\n'); return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 448 ms 76888 KB Output is correct
2 Correct 441 ms 76792 KB Output is correct
3 Correct 457 ms 74616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 20 ms 4992 KB Output is correct
15 Correct 20 ms 5120 KB Output is correct
16 Correct 19 ms 4480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 494 ms 78840 KB Output is correct
2 Correct 426 ms 78704 KB Output is correct
3 Correct 445 ms 76792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 448 ms 76888 KB Output is correct
2 Correct 441 ms 76792 KB Output is correct
3 Correct 457 ms 74616 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 20 ms 4992 KB Output is correct
18 Correct 20 ms 5120 KB Output is correct
19 Correct 19 ms 4480 KB Output is correct
20 Correct 494 ms 78840 KB Output is correct
21 Correct 426 ms 78704 KB Output is correct
22 Correct 445 ms 76792 KB Output is correct
23 Correct 684 ms 89168 KB Output is correct
24 Correct 674 ms 227908 KB Output is correct
25 Correct 660 ms 209156 KB Output is correct