Submission #1049478

#TimeUsernameProblemLanguageResultExecution timeMemory
1049478Dennis_JasonSails (IOI07_sails)C++14
25 / 100
26 ms1880 KiB
#include <bitset> #include <cmath> #include <functional> #include <algorithm> #include <numeric> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <unordered_map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <cstring> #include <climits> #define int long long #define pb push_back #define MOD 1000000007 #define NMAX 250001 #define nl '\n' #define INF 1000000007 #define pii1 pair<int, pair<int,int>> (1,(1,2)); #define pii pair<int,int> #define tpl tuple<int,int,int> using namespace std; ifstream fin("data.in"); ofstream fout("data.out"); /* --------------------DEMONSTRATION--------------------- 3-2 5-3 4-1 2-1 4-3 3-2 subtask 1:1<=n<=15; 5*(5+1)/2=10; 1+2+3+4+5=15 ------------------------END-------------------------- */ int n,h,k; int max_h; vector<pii>v; void subtask1() { map<int,int>mp; for(int i=1;i<=max_h;++i) { mp[i]=0; } for(int i=1;i<=n;++i) { int maxi=v[i].first; int cnt=v[i].second; vector<int>aux; for(auto [x,y]:mp) { if(x>maxi) continue; aux.pb(x); } auto cmp=[&](int a,int b) { if(mp[a]==mp[b]) return a>b; return mp[a]<mp[b]; }; sort(aux.begin(),aux.end(),cmp); for(auto x:aux) { if(!cnt) break; cnt--; mp[x]++; } } int ans=0; for(int i=1;i<=max_h;++i) { // cout<<mp[i]-1<<" "; if(mp[i]) { mp[i]--; ans+=(mp[i]*(mp[i]+1))/2; } } cout<<ans; } signed main() { cin>>n; v.resize(n+1); for(int i=1;i<=n;++i) { cin>>h>>k; v[i]={h,k}; max_h=max(max_h,h); } if(n<=15) { subtask1(); return 0; } else cout<<0; return 0; }

Compilation message (stderr)

sails.cpp: In function 'void subtask1()':
sails.cpp:69:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   69 |         for(auto [x,y]:mp)
      |                  ^
#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...