제출 #362514

#제출 시각아이디문제언어결과실행 시간메모리
362514flappybirdBoat (APIO16_boat)C++14
9 / 100
2096 ms162924 KiB
#include <bits/stdc++.h>
using namespace std;
#define MAX 510
#define all(v) v.begin(), v.end()
#define ln '\n'
#define MOD 1000000007
#define INF 210000000000
#define pb push_back
#define abs(x) (((x)>0)?(x):(-(x)))
#define len(x) ((x).second-(x).first)
typedef long long ll;
map<int, int> m;
int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	int i, j, k;
	int a, b;
	int sum;
	m[0] = 1;
	map<int, int>::iterator it;
	for (i = 1; i <= N; i++) {
		cin >> a >> b;
		sum = 0;
		for (it = m.begin(); it != m.end(); it++) {
			if (it->first > b) break;
			sum += it->second;
			sum %= MOD;
		}
		for (j = b; j >= a; j--) {
			sum -= m[j];
			m[j] += sum;
			m[j] %= MOD;
			sum %= MOD;
		}
	}
	sum = 0;
	for (it = m.begin(); it != m.end(); it++) {
		if(it->first) sum += it->second, sum %= MOD;
	}
	while (sum < 0) sum += MOD;
	cout << sum << ln;
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

boat.cpp: In function 'int main()':
boat.cpp:18:12: warning: unused variable 'k' [-Wunused-variable]
   18 |  int i, j, k;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...