Submission #637763

# Submission time Handle Problem Language Result Execution time Memory
637763 2022-09-03T07:21:38 Z victor_gao Ants and Sugar (JOI22_sugar) C++17
6 / 100
4000 ms 3244 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int q,l;
set<pii>ant,cube;
int count(){
    vector<pii>a,c;
    for (auto i:ant)
        a.push_back(i);
    for (auto i:cube)
        c.push_back(i);
    int p=0,ans=0;
    for (auto i:c){
        while (p<a.size()&&(i.x-a[p].x>l||a[p].y==0)){
            p++;   
        }
        pii now=i;
        while (p<a.size()&&now.y>0&&a[p].x-now.x<=l){
            int take=min(now.y,a[p].y);
            ans+=take;
            a[p].y-=take;
            now.y-=take;
            if (a[p].y==0) p++;
        }
    }
    return ans;
}
signed main(){
    fast
    cin>>q>>l;
    for (int i=1;i<=q;i++){
        int t,x,a; cin>>t>>x>>a;
        if (t==1){
            ant.insert({x,a});
        }
        else {
            cube.insert({x,a});
        }
        cout<<count()<<'\n';
    }
}

Compilation message

sugar.cpp: In function 'long long int count()':
sugar.cpp:26:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while (p<a.size()&&(i.x-a[p].x>l||a[p].y==0)){
      |                ~^~~~~~~~~
sugar.cpp:30:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while (p<a.size()&&now.y>0&&a[p].x-now.x<=l){
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 30 ms 508 KB Output is correct
7 Correct 28 ms 460 KB Output is correct
8 Correct 9 ms 340 KB Output is correct
9 Correct 7 ms 340 KB Output is correct
10 Correct 74 ms 688 KB Output is correct
11 Correct 73 ms 688 KB Output is correct
12 Correct 66 ms 816 KB Output is correct
13 Correct 66 ms 696 KB Output is correct
14 Correct 64 ms 672 KB Output is correct
15 Correct 57 ms 716 KB Output is correct
16 Correct 60 ms 636 KB Output is correct
17 Correct 50 ms 596 KB Output is correct
18 Correct 48 ms 648 KB Output is correct
19 Correct 66 ms 664 KB Output is correct
20 Correct 51 ms 672 KB Output is correct
21 Correct 66 ms 640 KB Output is correct
22 Correct 52 ms 628 KB Output is correct
23 Correct 67 ms 584 KB Output is correct
24 Correct 51 ms 688 KB Output is correct
25 Correct 71 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Execution timed out 4059 ms 2704 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 4082 ms 3244 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 30 ms 508 KB Output is correct
7 Correct 28 ms 460 KB Output is correct
8 Correct 9 ms 340 KB Output is correct
9 Correct 7 ms 340 KB Output is correct
10 Correct 74 ms 688 KB Output is correct
11 Correct 73 ms 688 KB Output is correct
12 Correct 66 ms 816 KB Output is correct
13 Correct 66 ms 696 KB Output is correct
14 Correct 64 ms 672 KB Output is correct
15 Correct 57 ms 716 KB Output is correct
16 Correct 60 ms 636 KB Output is correct
17 Correct 50 ms 596 KB Output is correct
18 Correct 48 ms 648 KB Output is correct
19 Correct 66 ms 664 KB Output is correct
20 Correct 51 ms 672 KB Output is correct
21 Correct 66 ms 640 KB Output is correct
22 Correct 52 ms 628 KB Output is correct
23 Correct 67 ms 584 KB Output is correct
24 Correct 51 ms 688 KB Output is correct
25 Correct 71 ms 684 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Execution timed out 4059 ms 2704 KB Time limit exceeded
30 Halted 0 ms 0 KB -