A 签到:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
cout<<n+n*n+n*n*n<<endl;
return 0;
}
B 签到:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
string s;
string t;
cin>>s;
cin>>t;
int tot = 0;
int len = s.length();
for(int i=0;i<len;i++){
if(s[i]!=t[i]) tot++;
}
cout<<tot<<endl;
}
C 很简单的一个题,但好像是少考虑什么了嘛?!!一直W 经过强哥的简单指导,不能只考虑局部每次两个桌子上取最小的 比如 1000 1 1 1 998 998 998 1003 是吧 一开始我想的就是局部最优每次,这样贪心以为能够取到最多的书 但其中这种情况下,你只能选择取第一个桌子上的书
#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;
int N,M,K;
ll w1[maxn],w2[maxn];
void solve(){
int ans = 0;
for(int i = 1;i<=M;i++) w2[i] += w2[i-1];
int idx = upper_bound(w2+1,w2+M+1,K) - w2;
ans = idx-1;
for(int i =1;i<=N;i++){
if(K>=w1[i]){
K-=w1[i];
int idx = upper_bound(w2+1,w2+M+1,K) - w2;
ans = max(ans,i + idx-1);
}else break;
}
cout<<ans<<'\n';
}
int main(){
// debug;
ios;
cin>>N>>M>>K;
for(int i =1;i<=N;i++) cin>>w1[i];
for(int i =1;i<=M;i++) cin>>w2[i];
solve();
return 0;
}
}