답안 #22205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22205 2017-04-29T18:52:31 Z 내일 시험이에요(#1036, pjh0123) 구간들 (KRIII5P_3) C++11
0 / 7
0 ms 1964 KB
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const ll mod = 1000000007;

int n;
pii a[101010];
priority_queue<int, vector<int>, greater<int> > pq;
int c;
int pow2(int x){
    ll t = 2;
    ll r = 1;
    while(x){
        if(x&1){
            r = (r*t)%mod;
        }
        t = (t*t)%mod;
        x/=2;
    }
    return int(r);
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i].first, &a[i].second);
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        while(!pq.empty() && pq.top() < a[i].first){
            pq.pop();
        }
        c = (c+pow2(pq.size()))%mod;
        pq.push(a[i].second);
    }
    printf("0 %d\n",c);

}

Compilation message

i.cpp: In function 'int main()':
i.cpp:26:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
i.cpp:28:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a[i].first, &a[i].second);
                                                ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1964 KB Output isn't correct
2 Halted 0 ms 0 KB -