답안 #104249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104249 2019-04-04T12:02:27 Z dupreez Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 116856 KB
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#define mk make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007,N=10000010;
int n,mxv,st[N],sti;

void push(int v1) {
	st[sti] = v1;
	sti++;
}

void pop() {
	sti--;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) { 
		int v1, v2;
		scanf("%d%d", &v1,&v2);
		if (i == 1) {
			mxv = v1 + v2;
			push(v1 - v2);
		}
		else if (mxv < v1 + v2) {
			while (sti!=0 && st[sti-1] >= v1 - v2)pop();
			push(v1 - v2);
			mxv = v1 + v2;
		}
	}
	cout << sti << endl;
	return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
lightningrod.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &v1,&v2);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 46844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 284 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 284 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 284 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 64 ms 1276 KB Output is correct
15 Correct 53 ms 1232 KB Output is correct
16 Correct 46 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1853 ms 40664 KB Output is correct
2 Execution timed out 2068 ms 116856 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 46844 KB Time limit exceeded
2 Halted 0 ms 0 KB -