Submission #1049461

#TimeUsernameProblemLanguageResultExecution timeMemory
1049461Dennis_JasonSails (IOI07_sails)C++14
0 / 100
25 ms1884 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<=4, 1<=h<=9 ,1<=k<=4; 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=n;i>=1;--i) { int cnt=v[i].second; bool used[cnt+1]; memset(used,false,sizeof(used)); for(int j=v[i].first;j>=1 && cnt;--j) { if(!mp[j]) { used[j]=1; cnt--; mp[j]++; } } if(cnt) { vector<int>aux; for(auto [x,y]:mp) { if(used[x] || x>v[i].first) 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<10) { subtask1(); return 0; } else cout<<0; return 0; }

Compilation message (stderr)

sails.cpp: In function 'void subtask1()':
sails.cpp:78:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   78 |             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...