NOIP 2016提高组 Day2 蚯蚓
2018-01-04 21:47
218 查看
直觉 用大根堆堆 用STL的priority_que 实现的; 过了七组数据,还有13组数据未过
收到网上“”记录时间戳“的思路的启发”,将所有的蚯蚓长度都折算到0时刻的长度(可能有负值)
通过了了16组数据,还有4组数据未通过。
#include <bits/stdc++.h>
using namespace std;
const int MM=100000;
int n,m,q,u,v,t;
//那只蚯蚓 m:时间 q:增加的长度 p=u/v
int qiuyin[MM];
priority_queue<int> que; //记录0时刻的蚯蚓的长度
int main(){
cin >> n >> m >> q >>u >> v>>t;
for(int i=0;i<n;i++){
cin >> qiuyin[i];
}
for(int i=0;i<n;i++){
que.push( qiuyin[i] );
}
for(int i=1;i<=m;i++){
int large = que.top() + (i-1)*q;
que.pop();
if( i>=t && i%t==0) cout << large << " ";
int new1= int( 1.0*large*u/v);
int new2= large- new1;
// cout<<"debug: new1 new2"<< new1 <<" "<< new2<<" "<<endl;
que.push(new1 - i*q);
que.push(new2 - i*q);
}
cout << endl;
int ge=0;
while(!que.empty()){
int ans=que.top() + m * q;
que.pop();
ge++;
if( ge>=t && ge%t==0 && ans>=0 ) cout << ans<< " ";
}
return 0;
}
#include <bits/stdc++.h> using namespace std; const int MM=100000; int n,m,q,u,v,t; //那只蚯蚓 m:时间 q:增加的长度 p=u/v int qiuyin[MM]; vector<int> qiuyin2; priority_queue<int> que; int main(){ cin >> n >> m >> q >>u >> v>>t; for(int i=0;i<n;i++){ cin >> qiuyin[i]; } for(int i=0;i<n;i++){ que.push( qiuyin[i] ); } for(int i=1;i<=m;i++){ int large = 0; if(!que.empty()) { large = que.top(); que.pop(); if( i>=t && i%t==0) cout << large << " "; } qiuyin2.clear(); while(!que.empty()){ qiuyin2.push_back(que.top()); //cout<< "debug :"<<que.top() << " "<<endl; que.pop(); } for(int j=0;j<qiuyin2.size();j++){ qiuyin2[j] += q; que.push( qiuyin2[j] ); } //double p= 1.0*u/v; //cout <<"debug p" << p<<endl; int new1= int( 1.0*large*u/v); int new2= large- new1; //cout<<"debug: new1 new2"<< new1 <<" "<< new2<<" "<<endl; que.push(new1); que.push(new2); } cout << endl; int ge=0; while(!que.empty()){ int temp=que.top(); que.pop(); ge++; if( ge>=t && ge%t==0) cout << temp << " "; } return 0; }
收到网上“”记录时间戳“的思路的启发”,将所有的蚯蚓长度都折算到0时刻的长度(可能有负值)
通过了了16组数据,还有4组数据未通过。
#include <bits/stdc++.h>
using namespace std;
const int MM=100000;
int n,m,q,u,v,t;
//那只蚯蚓 m:时间 q:增加的长度 p=u/v
int qiuyin[MM];
priority_queue<int> que; //记录0时刻的蚯蚓的长度
int main(){
cin >> n >> m >> q >>u >> v>>t;
for(int i=0;i<n;i++){
cin >> qiuyin[i];
}
for(int i=0;i<n;i++){
que.push( qiuyin[i] );
}
for(int i=1;i<=m;i++){
int large = que.top() + (i-1)*q;
que.pop();
if( i>=t && i%t==0) cout << large << " ";
int new1= int( 1.0*large*u/v);
int new2= large- new1;
// cout<<"debug: new1 new2"<< new1 <<" "<< new2<<" "<<endl;
que.push(new1 - i*q);
que.push(new2 - i*q);
}
cout << endl;
int ge=0;
while(!que.empty()){
int ans=que.top() + m * q;
que.pop();
ge++;
if( ge>=t && ge%t==0 && ans>=0 ) cout << ans<< " ";
}
return 0;
}
相关文章推荐
- 【NOIP2016提高组day2】蚯蚓
- 蚯蚓 NOIP2016 提高组 Day2 T2
- NOIP2016 提高组 DAY2 解题思路
- 【NOIP2016提高组】蚯蚓
- noip2016 Day2 T2:蚯蚓 (归并)
- NOIP2016 提高组 第二天第二题 蚯蚓earthworm 题解
- NOIP2016全国信息学分区联赛提高组第二试 蚯蚓
- Noip 2016 提高组第二试 蚯蚓
- 【NOIP 2016 day2 T1 T2】组合数问题,蚯蚓——题解
- 【NOIP2016提高A组模拟8.19】(雅礼联考day2)树上路径
- UOJ264 NOIP2016 day2 T2 蚯蚓(队列)
- NOIP2016全国信息学分区联赛提高组第二试 蚯蚓
- 【jzoj4907】【NOIP2016提高组】【蚯蚓】【单调队列】
- 【NOIP 2016 提高组】蚯蚓
- 【NOIP】提高组2016 蚯蚓
- 2016 noip day2蚯蚓总结
- 【NOIP2016提高组复赛】蚯蚓
- {小结}NOIP2016提高A组模拟8.19(雅礼联考day2)
- 【NOIP2016提高A组模拟8.19】(雅礼联考day2)公约数
- 【NOIP2016提高A组模拟8.19】(雅礼联考day2)总结