Submission #661139

# Submission time Handle Problem Language Result Execution time Memory
661139 2022-11-24T16:18:33 Z activedeltorre Boat (APIO16_boat) C++14
31 / 100
565 ms 524288 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
vector<int>norm;
map<int,int>mp;
pair<int,int>vec[505];
long long aib[1000005];
long long mod=1000000007;
int cnt=1;
void update(int poz,long val)
{
    while(poz<=cnt)
    {
        aib[poz]=(aib[poz]+val)%mod;
        poz=poz+(poz&(-poz));
    }
}
long long query(int poz)
{
    long long suma=0;
    while(poz>0)
    {
        suma=(suma+aib[poz])%mod;
        poz=poz-(poz&(-poz));
    }
    return suma;
}
int dp[10000005];
int main()
{
    long long val,n,i,j,k,x;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>vec[i].first;
        cin>>vec[i].second;
        for(j=vec[i].first;j<=vec[i].second;j++)
        {
            norm.push_back(j);
        }
    }
    norm.push_back(0);
    sort(norm.begin(),norm.end());
    for(i=0;i<norm.size();i++)
    {
        if(mp[norm[i]]==0)
        {
            mp[norm[i]]=cnt;
            cnt++;
        }
    }
    ///la poz 1 se alfa adaca nu tirmite barci
    update(1,1);
    for(i=1;i<n;i++)
    {
        for(j=vec[i].second;j>=vec[i].first;j--)
        {
            x=mp[j];
            val=query(x-1);
            update(x,val);
        }
    }
    long long suma=-1;
    for(j=vec[i].second;j>=vec[i].first;j--)
    {
        x=mp[j];
        suma=(suma+query(x-1))%mod;
    }
    suma=(suma+query(cnt))%mod;
    cout<<suma;
    return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:47:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(i=0;i<norm.size();i++)
      |             ~^~~~~~~~~~~~
boat.cpp:34:25: warning: unused variable 'k' [-Wunused-variable]
   34 |     long long val,n,i,j,k,x;
      |                         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 244 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 244 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 121 ms 4548 KB Output is correct
22 Correct 102 ms 4548 KB Output is correct
23 Correct 100 ms 4548 KB Output is correct
24 Correct 106 ms 4460 KB Output is correct
25 Correct 114 ms 4548 KB Output is correct
26 Correct 116 ms 4548 KB Output is correct
27 Correct 109 ms 4488 KB Output is correct
28 Correct 109 ms 4548 KB Output is correct
29 Correct 111 ms 4520 KB Output is correct
30 Correct 565 ms 58072 KB Output is correct
31 Correct 557 ms 56924 KB Output is correct
32 Correct 561 ms 57900 KB Output is correct
33 Correct 531 ms 56844 KB Output is correct
34 Correct 565 ms 57184 KB Output is correct
35 Correct 499 ms 54784 KB Output is correct
36 Correct 495 ms 56696 KB Output is correct
37 Correct 513 ms 57400 KB Output is correct
38 Correct 505 ms 55388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 543 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 244 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 121 ms 4548 KB Output is correct
22 Correct 102 ms 4548 KB Output is correct
23 Correct 100 ms 4548 KB Output is correct
24 Correct 106 ms 4460 KB Output is correct
25 Correct 114 ms 4548 KB Output is correct
26 Correct 116 ms 4548 KB Output is correct
27 Correct 109 ms 4488 KB Output is correct
28 Correct 109 ms 4548 KB Output is correct
29 Correct 111 ms 4520 KB Output is correct
30 Correct 565 ms 58072 KB Output is correct
31 Correct 557 ms 56924 KB Output is correct
32 Correct 561 ms 57900 KB Output is correct
33 Correct 531 ms 56844 KB Output is correct
34 Correct 565 ms 57184 KB Output is correct
35 Correct 499 ms 54784 KB Output is correct
36 Correct 495 ms 56696 KB Output is correct
37 Correct 513 ms 57400 KB Output is correct
38 Correct 505 ms 55388 KB Output is correct
39 Runtime error 543 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -