답안 #61188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61188 2018-07-25T10:26:30 Z dukati8 Boat (APIO16_boat) C++14
9 / 100
2000 ms 525312 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)
long long m=1e9+7;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  rep(i,0,n) {
    cin >> a[i] >> b[i];
  }
  unordered_map<long long, long long> x;
  x[0]=1;
  rep (i,0,n) {
    long long lo,hi;
    lo=a[i];
    hi=b[i];
    long long sum=0;
    vector<pair<long long, long long>> save;
    for (auto c:x) {

      long long size=c.first;
      long long num=c.second;
      //cout << size << " " << num <<  endl;
      if (size<lo) {sum+=num; sum%=m;}
      else if (size<hi) save.push_back(c);
    }
    //cout << endl;
    sort(save.begin(),save.end());
    long long j=0;
    rep (i,lo,hi+1) {
      while(j<save.size() &&save[j].first<i) {
        sum+=save[j].second;
        sum%=m;
        j++;
      }
      if (x.find(i)==x.end()) {
        x[i]=sum;
      }
      else {
        x[i]+=sum;
        x[i]%=m;
      }
    }
  }
  long long sum=0;
  for (auto c:x){
    sum+=c.second;
    sum%=m;
    //cout << c.first << " " << c.second << endl;
  }
  sum+=m;
  sum-=1;
  sum%=m;
  cout << sum << endl;


}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:34:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while(j<save.size() &&save[j].first<i) {
             ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 6 ms 472 KB Output is correct
5 Correct 5 ms 516 KB Output is correct
6 Correct 5 ms 592 KB Output is correct
7 Correct 5 ms 720 KB Output is correct
8 Correct 6 ms 720 KB Output is correct
9 Correct 5 ms 720 KB Output is correct
10 Correct 6 ms 720 KB Output is correct
11 Correct 5 ms 720 KB Output is correct
12 Correct 5 ms 720 KB Output is correct
13 Correct 7 ms 720 KB Output is correct
14 Correct 7 ms 720 KB Output is correct
15 Correct 6 ms 720 KB Output is correct
16 Correct 4 ms 748 KB Output is correct
17 Correct 4 ms 748 KB Output is correct
18 Correct 3 ms 748 KB Output is correct
19 Correct 4 ms 748 KB Output is correct
20 Correct 4 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 6 ms 472 KB Output is correct
5 Correct 5 ms 516 KB Output is correct
6 Correct 5 ms 592 KB Output is correct
7 Correct 5 ms 720 KB Output is correct
8 Correct 6 ms 720 KB Output is correct
9 Correct 5 ms 720 KB Output is correct
10 Correct 6 ms 720 KB Output is correct
11 Correct 5 ms 720 KB Output is correct
12 Correct 5 ms 720 KB Output is correct
13 Correct 7 ms 720 KB Output is correct
14 Correct 7 ms 720 KB Output is correct
15 Correct 6 ms 720 KB Output is correct
16 Correct 4 ms 748 KB Output is correct
17 Correct 4 ms 748 KB Output is correct
18 Correct 3 ms 748 KB Output is correct
19 Correct 4 ms 748 KB Output is correct
20 Correct 4 ms 748 KB Output is correct
21 Correct 135 ms 1220 KB Output is correct
22 Correct 120 ms 1220 KB Output is correct
23 Correct 121 ms 1220 KB Output is correct
24 Correct 141 ms 1220 KB Output is correct
25 Correct 132 ms 1220 KB Output is correct
26 Correct 129 ms 1220 KB Output is correct
27 Correct 143 ms 1220 KB Output is correct
28 Correct 181 ms 1220 KB Output is correct
29 Correct 170 ms 1220 KB Output is correct
30 Execution timed out 2054 ms 25388 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2063 ms 525312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 6 ms 472 KB Output is correct
5 Correct 5 ms 516 KB Output is correct
6 Correct 5 ms 592 KB Output is correct
7 Correct 5 ms 720 KB Output is correct
8 Correct 6 ms 720 KB Output is correct
9 Correct 5 ms 720 KB Output is correct
10 Correct 6 ms 720 KB Output is correct
11 Correct 5 ms 720 KB Output is correct
12 Correct 5 ms 720 KB Output is correct
13 Correct 7 ms 720 KB Output is correct
14 Correct 7 ms 720 KB Output is correct
15 Correct 6 ms 720 KB Output is correct
16 Correct 4 ms 748 KB Output is correct
17 Correct 4 ms 748 KB Output is correct
18 Correct 3 ms 748 KB Output is correct
19 Correct 4 ms 748 KB Output is correct
20 Correct 4 ms 748 KB Output is correct
21 Correct 135 ms 1220 KB Output is correct
22 Correct 120 ms 1220 KB Output is correct
23 Correct 121 ms 1220 KB Output is correct
24 Correct 141 ms 1220 KB Output is correct
25 Correct 132 ms 1220 KB Output is correct
26 Correct 129 ms 1220 KB Output is correct
27 Correct 143 ms 1220 KB Output is correct
28 Correct 181 ms 1220 KB Output is correct
29 Correct 170 ms 1220 KB Output is correct
30 Execution timed out 2054 ms 25388 KB Time limit exceeded
31 Halted 0 ms 0 KB -