Submission #77286

# Submission time Handle Problem Language Result Execution time Memory
77286 2018-09-24T17:27:30 Z MohamedAhmed0 Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 43616 KB
#include <bits/stdc++.h>

using namespace std;

long long dp[100001] ;

int main()
{
    long long n ;
    cin>>n ;
    map<long long , long long>mp ;
    for(long long i = 0 ; i < n ; ++i)
    {
        long long x , y ;
        cin>>x>>y;
        mp[x] += y ;
    }
    vector< pair<long long , long long> >vp ;
    for(auto &i : mp)
      vp.push_back({i.first , i.second});
    long long ans = vp[0].second;
    dp[0] = vp[0].second;
    for(long long i = 1 ; i < vp.size() ; ++i)
    {
       dp[i] = max(vp[i].second , vp[i].second + dp[i-1] - (vp[i].first - vp[i-1].first));
       ans = max(ans , dp[i]);
    }
    cout<<ans<<"\n";
    return 0 ;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:23:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(long long i = 1 ; i < vp.size() ; ++i)
                           ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 552 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 2 ms 648 KB Output is correct
17 Correct 3 ms 656 KB Output is correct
18 Correct 2 ms 664 KB Output is correct
19 Correct 2 ms 672 KB Output is correct
20 Correct 3 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 2 ms 824 KB Output is correct
25 Correct 2 ms 824 KB Output is correct
26 Correct 2 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 552 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 2 ms 648 KB Output is correct
17 Correct 3 ms 656 KB Output is correct
18 Correct 2 ms 664 KB Output is correct
19 Correct 2 ms 672 KB Output is correct
20 Correct 3 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 2 ms 824 KB Output is correct
25 Correct 2 ms 824 KB Output is correct
26 Correct 2 ms 832 KB Output is correct
27 Correct 10 ms 1404 KB Output is correct
28 Correct 10 ms 1532 KB Output is correct
29 Correct 9 ms 1660 KB Output is correct
30 Correct 10 ms 1788 KB Output is correct
31 Correct 10 ms 2044 KB Output is correct
32 Correct 10 ms 2056 KB Output is correct
33 Correct 10 ms 2180 KB Output is correct
34 Correct 10 ms 2380 KB Output is correct
35 Correct 12 ms 2436 KB Output is correct
36 Correct 10 ms 2692 KB Output is correct
37 Correct 10 ms 2692 KB Output is correct
38 Correct 10 ms 2840 KB Output is correct
39 Correct 10 ms 2964 KB Output is correct
40 Correct 10 ms 3092 KB Output is correct
41 Correct 10 ms 3220 KB Output is correct
42 Correct 14 ms 3344 KB Output is correct
43 Correct 10 ms 3472 KB Output is correct
44 Correct 10 ms 3600 KB Output is correct
45 Correct 10 ms 3728 KB Output is correct
46 Correct 9 ms 3856 KB Output is correct
47 Correct 10 ms 3984 KB Output is correct
48 Correct 10 ms 4120 KB Output is correct
49 Correct 10 ms 4236 KB Output is correct
50 Correct 11 ms 4320 KB Output is correct
51 Correct 10 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 552 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 2 ms 648 KB Output is correct
17 Correct 3 ms 656 KB Output is correct
18 Correct 2 ms 664 KB Output is correct
19 Correct 2 ms 672 KB Output is correct
20 Correct 3 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 824 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 2 ms 824 KB Output is correct
25 Correct 2 ms 824 KB Output is correct
26 Correct 2 ms 832 KB Output is correct
27 Correct 10 ms 1404 KB Output is correct
28 Correct 10 ms 1532 KB Output is correct
29 Correct 9 ms 1660 KB Output is correct
30 Correct 10 ms 1788 KB Output is correct
31 Correct 10 ms 2044 KB Output is correct
32 Correct 10 ms 2056 KB Output is correct
33 Correct 10 ms 2180 KB Output is correct
34 Correct 10 ms 2380 KB Output is correct
35 Correct 12 ms 2436 KB Output is correct
36 Correct 10 ms 2692 KB Output is correct
37 Correct 10 ms 2692 KB Output is correct
38 Correct 10 ms 2840 KB Output is correct
39 Correct 10 ms 2964 KB Output is correct
40 Correct 10 ms 3092 KB Output is correct
41 Correct 10 ms 3220 KB Output is correct
42 Correct 14 ms 3344 KB Output is correct
43 Correct 10 ms 3472 KB Output is correct
44 Correct 10 ms 3600 KB Output is correct
45 Correct 10 ms 3728 KB Output is correct
46 Correct 9 ms 3856 KB Output is correct
47 Correct 10 ms 3984 KB Output is correct
48 Correct 10 ms 4120 KB Output is correct
49 Correct 10 ms 4236 KB Output is correct
50 Correct 11 ms 4320 KB Output is correct
51 Correct 10 ms 4444 KB Output is correct
52 Execution timed out 1078 ms 43616 KB Time limit exceeded
53 Halted 0 ms 0 KB -