Submission #138523

#TimeUsernameProblemLanguageResultExecution timeMemory
138523BoxworldSails (IOI07_sails)C++14
40 / 100
1068 ms3280 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int maxN=100100; pii a[maxN]; int s[maxN]; priority_queue<pii,vector<pii>,greater<pii> > Q; queue<int> Q1; int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second); sort(a,a+n); int tmp=1; for(int i=0;i<n;i++){ for (int j=tmp;j<=a[i].first;j++)Q.push(make_pair(0,j)); for (int j=0;j<a[i].second;j++){ pii P=Q.top();Q.pop(); s[P.second]++; Q1.push(P.second); } while(!Q1.empty()){ int x=Q1.front();Q1.pop(); Q.push(make_pair(s[x],x)); } tmp=a[i].first+1; } long long ans=0; for (int i=1;i<tmp;i++)ans+=s[i]*(s[i]-1)/2; printf("%lld\n",ans); return 0; }

Compilation message (stderr)

sails.cpp: In function 'int main()':
sails.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
sails.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...