답안 #26202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26202 2017-06-28T10:50:28 Z Extazy Boat (APIO16_boat) C++14
0 / 100
2000 ms 209136 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 517;
const int MOD = (1e9) + 7;

int n;
pair < int, int > a[N];
map < int, int > inside;
map < int, int >::iterator it;
int last;
long long ans;

int main() {
    int i,j;
    
    scanf("%d", &n);
    for(i=1;i<=n;i++) {
        scanf("%d %d", &a[i].first, &a[i].second);
        ++inside[a[i].first];
        --inside[a[i].second+1];
    }
    
    for(i=1;i<=n;i++) {
        for(j=a[i].first;j<=a[i].second;j++) if(inside.find(j)==inside.end()) inside.insert(make_pair(j,0));
    }

    last=0;
    for(it=inside.begin();it!=inside.end();it++) {
        it->second+=last;
        it->second%=MOD;
        if(it->second) ans+=it->second+1;
        last=it->second;
    }

    ans%=MOD;
    printf("%lld\n", ans);

    return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:18:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
boat.cpp:20:50: 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 2028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2000 ms 209136 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2028 KB Output isn't correct
2 Halted 0 ms 0 KB -