Submission #1208397

#TimeUsernameProblemLanguageResultExecution timeMemory
1208397salmonAnts and Sugar (JOI22_sugar)C++20
6 / 100
4093 ms7892 KiB
#include <bits/stdc++.h> using namespace std; int N; int L; map<int,long long int> mep1,mep2; int main(){ scanf(" %d",&N); scanf(" %d",&L); for(int i = 0; i < N; i++){ int h; int h1; scanf(" %d",&h); if(h == 1){ scanf(" %d",&h); scanf(" %d",&h1); mep1[h] += h1; } else{ scanf(" %d",&h); scanf(" %d",&h1); mep2[h] += h1; } long long int ans = 0; auto it1 = mep2.begin(); long long int sob = 0; for(pair<int,long long int> ii : mep1){ while(it1 != mep2.end() && it1 -> first < ii.first - L){ advance(it1,1); sob = 0; } if(it1 == mep2.end()) break; if(ii.first + L < it1 -> first ) continue; long long int temp = ii.second; while(it1 != mep2.end() && temp >= it1 -> second - sob){ if(ii.first + L < it1 -> first ) break; ans += it1 -> second - sob; temp -= it1 -> second - sob; sob = 0; advance(it1,1); } if(it1 == mep2.end()) break; if(ii.first + L < it1 -> first ) continue; if(temp != 0){ ans += temp; sob += temp; } } printf("%lld\n",ans); } }

Compilation message (stderr)

sugar.cpp: In function 'int main()':
sugar.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf(" %d",&N);
      |         ~~~~~^~~~~~~~~~
sugar.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf(" %d",&L);
      |         ~~~~~^~~~~~~~~~
sugar.cpp:17:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |                 scanf(" %d",&h);
      |                 ~~~~~^~~~~~~~~~
sugar.cpp:20:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |                         scanf(" %d",&h);
      |                         ~~~~~^~~~~~~~~~
sugar.cpp:21:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |                         scanf(" %d",&h1);
      |                         ~~~~~^~~~~~~~~~~
sugar.cpp:25:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |                         scanf(" %d",&h);
      |                         ~~~~~^~~~~~~~~~
sugar.cpp:26:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |                         scanf(" %d",&h1);
      |                         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...