#include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <string.h> #include <set> #include <string> #include <map> #include <iostream> #include <queue> #include <unordered_set> #include <stdlib.h> #include <sstream> #include <iomanip> typedef long long ll; using namespace std; const int N = 2e5 + 7; int T; int n, q, m; int main() { cin >> T; while (T--) { cin>>n>>q>>m; int t=q+m; int ans=0; if(n>0) { n--; ans++; } while(1) { if(t>0) { t--; ans++; } else { cout<<ans<<endl; break; } if(n>0) { n--; ans++; } else { cout<<ans-1<<endl; break; } } } system("pause"); return 0; }
#include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <string.h> #include <set> #include <string> #include <map> #include <iostream> #include <queue> #include <unordered_set> #include <stdlib.h> #include <sstream> #include <iomanip> typedef long long ll; using namespace std; const int N = 3e5 + 7; int T; int n, q, m; struct Node { int i; int num; }node[N]; bool cmp(Node a, Node b) { if(a.num == b.num) { if(a.i<b.i) { return true; } else { return false; } } else { return a.num>b.num; } } int main() { cin >> T; while (T--) { int k; cin>>n>>k; //int a[N]; for(int i=0; i<n;i++) { cin>>node[i].num; node[i].num=node[i].num%k; if(node[i].num==0) { node[i].num= k; } node[i].i=i+1; } int flag=0; sort(node,node+n,cmp); //node[0].num-=k; for(int i=0;i<n;i++) { cout<<node[i].i<<" "; } cout<<endl; } system("pause"); return 0; }
标签:node,Educational,Rated,int,Codeforces,--,num,ans,include From: https://www.cnblogs.com/oliverfg/p/17588819.html