답안 #699327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699327 2023-02-16T15:06:09 Z Rahal Art Exhibition (JOI18_art) C++17
50 / 100
1000 ms 16220 KB
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
///Constants
//int mod = 1000000007;
/*void setIO(string s)
{
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}*/
signed main()
{
    IOS;
    int n, a, b;
    cin >> n;
    vector<pair<int, int>>v;
    vector<int>pre;
    v.push_back({0, 0});
    for(int i = 0 ; i < n ; ++i){
      cin >> a >> b;
      v.push_back({a, b});
    }
    sort(v.begin(), v.end());
    a = 0;
    for(int i = 0 ; i <= n ; ++i){
      a+=v[i].second;
      pre.push_back(a);
    }
    int mx = -1;
    for(int i = 0 ; i < n ; ++i){
      for(int j = i+1 ; j <= n ; ++j){
         mx = max(mx, (pre[j]-pre[i])-(v[j].first-v[i+1].first));
         //cout << i << " " << j << " " << mx << "\n";
      }
    }
    cout << mx ;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 16 ms 572 KB Output is correct
28 Correct 16 ms 468 KB Output is correct
29 Correct 15 ms 468 KB Output is correct
30 Correct 15 ms 580 KB Output is correct
31 Correct 15 ms 468 KB Output is correct
32 Correct 15 ms 576 KB Output is correct
33 Correct 17 ms 572 KB Output is correct
34 Correct 17 ms 532 KB Output is correct
35 Correct 17 ms 572 KB Output is correct
36 Correct 16 ms 468 KB Output is correct
37 Correct 15 ms 468 KB Output is correct
38 Correct 15 ms 468 KB Output is correct
39 Correct 15 ms 468 KB Output is correct
40 Correct 15 ms 468 KB Output is correct
41 Correct 18 ms 572 KB Output is correct
42 Correct 16 ms 468 KB Output is correct
43 Correct 17 ms 572 KB Output is correct
44 Correct 15 ms 468 KB Output is correct
45 Correct 15 ms 572 KB Output is correct
46 Correct 15 ms 468 KB Output is correct
47 Correct 17 ms 468 KB Output is correct
48 Correct 19 ms 468 KB Output is correct
49 Correct 15 ms 468 KB Output is correct
50 Correct 15 ms 468 KB Output is correct
51 Correct 15 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 16 ms 572 KB Output is correct
28 Correct 16 ms 468 KB Output is correct
29 Correct 15 ms 468 KB Output is correct
30 Correct 15 ms 580 KB Output is correct
31 Correct 15 ms 468 KB Output is correct
32 Correct 15 ms 576 KB Output is correct
33 Correct 17 ms 572 KB Output is correct
34 Correct 17 ms 532 KB Output is correct
35 Correct 17 ms 572 KB Output is correct
36 Correct 16 ms 468 KB Output is correct
37 Correct 15 ms 468 KB Output is correct
38 Correct 15 ms 468 KB Output is correct
39 Correct 15 ms 468 KB Output is correct
40 Correct 15 ms 468 KB Output is correct
41 Correct 18 ms 572 KB Output is correct
42 Correct 16 ms 468 KB Output is correct
43 Correct 17 ms 572 KB Output is correct
44 Correct 15 ms 468 KB Output is correct
45 Correct 15 ms 572 KB Output is correct
46 Correct 15 ms 468 KB Output is correct
47 Correct 17 ms 468 KB Output is correct
48 Correct 19 ms 468 KB Output is correct
49 Correct 15 ms 468 KB Output is correct
50 Correct 15 ms 468 KB Output is correct
51 Correct 15 ms 468 KB Output is correct
52 Execution timed out 1090 ms 16220 KB Time limit exceeded
53 Halted 0 ms 0 KB -