# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68428 | gusfring | Boat (APIO16_boat) | C++14 | 2052 ms | 525312 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505, MOD = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> pii;
#define a first
#define b second
int N, A[MAXN], B[MAXN], T[1000505], bit[1000505], res, sum;
vector<pii> vec;
void update(int pos, int val){
while(pos <= sum){
bit[pos] = (bit[pos] + val) % MOD;
pos += (pos & (-pos));
}
}
int query(int pos){
int r = 0;
while(pos){
r = (r + bit[pos]) % MOD;
pos -= (pos & (-pos));
}
return r;
}
ll solve(){
int cnt = 0;
for(int i=1; i<=N; ++i)
for(int j=B[i]; j>=A[i]; --j) vec.push_back({j, ++cnt});
sort(vec.begin(), vec.end());
T[vec[0].b] = 1, cnt = 1;
for(int i=1; i<vec.size(); ++i){
if(vec[i].a != vec[i - 1].a) cnt++;
T[vec[i].b] = cnt;
}
for(int i=1; i<=sum; ++i){
int r = (query(T[i] - 1) + 1) % MOD;
update(T[i], r);
res = (res + r) % MOD;
}
return res;
}
int main(){
scanf("%d", &N);
for(int i=1; i<=N; ++i){
scanf("%d %d", &A[i], &B[i]);
sum += B[i] - A[i] + 1;
}
printf("%lld\n", solve());
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |