QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#439329#8590. Problem Setternikaa1230 64ms9948kbC++171.7kb2024-06-11 19:40:302024-06-11 19:40:30

Judging History

你现在查看的是最新测评结果

  • [2024-06-11 19:40:30]
  • 评测
  • 测评结果:0
  • 用时:64ms
  • 内存:9948kb
  • [2024-06-11 19:40:30]
  • 提交

answer

// #pragma GCC diagnostic warnig "-std=c++11"
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pp pop_back
#define endl '\n'
#define ff first
#define ss second
#define stop exit(0)
#define sz(x) (int)x.size()
#define pause system("pause")
#define all(x) (x).begin(),(x).end()
#define deb(x) cout << #x << "-" << x  << endl
 
typedef char chr;
typedef string str;
// typedef long long ll;
typedef vector <int> vii;
typedef pair <int,int> pii;
 
const long long INF = LLONG_MAX;
const int inf = INT_MAX;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int dx[] = {0,0,-1,1};
const int dy[] = {-1,1,0,0};
const double PI = 2 * acos(0.0);

const int N = 2e5 + 5;

int n,m,cur,mx,ans;
pii a[N],b[N];

inline void test_case () {  
    
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].ff >> a[i].ss;
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i].ff >> b[i].ss;
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    cur = 1;
    mx = a[1].ss;
    for (int i = 1; i <= m; i++) {
        while (a[cur+1].ff <= b[i].ff && cur <= n) {
            cur++;
            mx = max(mx,a[cur].ss);
        }
        if (mx - b[i].ss > 0) ans += (mx - b[i].ss);
    }
    
    cout << ans << endl;

}
 
signed main () {
 
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int T = 1;
    // cin >> T;
    while(T--) {
        test_case();
    }
    
    return 0;
 
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3684kb

input:

1000 1
570339 324084
75781 292531
427864 843267
928484 613828
883296 385343
733451 782070
756314 89477
786410 133722
455015 841750
146307 536680
992681 107898
657731 633895
764691 258779
142935 640379
445046 717170
227758 578083
526095 660806
859673 757597
898726 4088
719881 887973
850810 674331
752...

output:

206661

result:

wrong answer 1st lines differ - expected: '575102', found: '206661'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #24:

score: 26
Accepted
time: 64ms
memory: 9860kb

input:

200000 200000
443848 257048
353855 430518
112240 460358
489050 850745
18217 643349
796031 335731
553602 81823
556808 39341
963397 797473
713023 273372
888193 500234
801660 980841
416233 163140
649254 659678
434013 461662
805451 259446
107168 839690
438518 100393
584335 435627
735040 11809
906814 672...

output:

199985649927

result:

ok single line: '199985649927'

Test #25:

score: 0
Wrong Answer
time: 59ms
memory: 9948kb

input:

200000 200000
333130 577648
41080 822997
187466 358241
16874 51949
553684 775680
888225 58652
283594 632965
971667 522676
73986 76332
905359 631172
633389 994061
934283 902840
110896 341628
432967 332824
239445 649641
689728 484799
124192 63092
153968 530823
906578 363019
287528 659642
141227 738119...

output:

199982909108

result:

wrong answer 1st lines differ - expected: '199982798008', found: '199982909108'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%