| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 22072 | 아재 goto 써요? (#42) | 구간들 (KRIII5P_3) | C++14 | 0 ms | 2024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// =====================================================================================
//
// Filename: i.cpp
// Created: 2017년 04월 29일 15시 53분 37초
// Compiler: g++ -O2 -std=c++14
// Author: baactree , bsj0206@naver.com
// Company: Chonnam National University
//
// =====================================================================================
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > event;
const int mod=1000000007;
typedef long long ll;
ll _pow(ll a, ll b){
if(b==0)
return 1;
ll temp=_pow(a, b/2);
temp=(temp*temp)%mod;
if(b&1)
return (temp*a)%mod;
return temp;
}
int main(){
scanf("%d", &n);
for(int i=0;i<n;i++){
int a, b;
scanf("%d%d", &a, &b);
if(a>=b)
continue;
event.push_back({a, 0});
event.push_back({b, 1});
}
sort(event.begin(), event.end());
int cnt=0;
int len=0;
int ans=0;
int pre=0;
for(int i=0;i<event.size();i++){
int x=event[i].first;
int m=event[i].second;
len+=(long long)(x-pre)*(_pow(2, cnt)-1+mod);
len%=mod;
if(!m){
ans+=_pow(2, cnt);
ans%=mod;
cnt++;
}
else{
cnt--;
}
pre=x;
}
printf("%d %d\n", len, ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
