# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26207 | Extazy | Boat (APIO16_boat) | C++14 | 2000 ms | 168944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 517;
const int TO = 1000000000;
const int KEY = 314487923;
const int MOD = (1e9) + 7;
int n;
pair < int, int > a[N];
unordered_map < int, int > it;
long long ans;
void update(int pos, int val) {
for(;pos<=TO;pos+=pos&(pos)) it[pos]+=val,it[pos]%=MOD;
}
int query(int pos) {
long long ans=1;
for(;pos>=1;pos-=pos&(-pos)) ans+=it[pos];
return ans%MOD;
}
int main() {
int i,j;
scanf("%d", &n);
for(i=1;i<=n;i++) {
scanf("%d %d", &a[i].first, &a[i].second);
}
for(i=1;i<=n;i++) {
//for(j=a[i].first;j<=a[i].second;j++) ans+=query(j-1)+1;
//for(j=a[i].first;j<=a[i].second;j++) update(j,1);
for(j=a[i].second;j>=a[i].first;j--) ans+=query(j-1),update(j,query(j-1));
}
ans%=MOD;
printf("%lld\n", ans);
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... |