QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714575 | #5465. Maximum GCD | zafirkenzaman | WA | 12ms | 4000kb | C++14 | 7.8kb | 2024-11-06 00:17:55 | 2024-11-06 00:17:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define mii map<int,int>
#define mll map<ll,ll>
#define mcl map<char,ll>
#define msl map<string,ll>
#define all(a) (a).begin(),(a).end()
#define rall(a) a.rbegin(),a.rend()
#define allg(x) x.begin(),x.end(),greater<int>()
#define maxel *max_element
#define minel *min_element
#define unq(v) v.resize(unique(v.begin(),v.end())-v.begin());
#define sorted(v) is_sorted(v.begin(),v.end())
#define YES cout << "YES"<<endl
#define NO cout << "NO"<<endl
#define Yes cout << "Yes"<<endl
#define No cout << "No"<<endl
#define MOD 1000000007 // 1e9+7
#define sz size()
#define vp vector<pair<ll,ll>>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define fr2(i,a,b) for(ll i=a;i>=b;i--)
void khuaitian()
{
ios::sync_with_stdio(0);
cin.tie(0);
}
#define read freopen("cricket.in","r",stdin)
#define write freopen("cricket.out","w",stdout)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll INF = LONG_MAX;
const int MIN = LONG_MIN;
//bool compare(pair<ll,ll> p1,pair<ll,ll>p2)
//{
// if(p1.first<p2.first)return false;
// else if(p1.first>p2.first)return true;
// return p1.second<p2.second;
//}
ll manhatan(ll x1, ll y1, ll x2, ll y2)
{
return abs(x1 - x2) + abs(y1 - y2);
}
//bool isPowerofTwo(ll n)
//{
// return (n && !(n&(n-1)));
//}
//int is_prime(int x)
//{
// for ( int i = 2; i*i <= x; i++ )
// {
// if ( x % i == 0 )
// {
// return i;
// }
// }
// return -1;
//}
//bool isperfectsqr(ll x)
//{
// ll y=sqrt(x);
// return y*y==x;
//}
//ll digitsum(ll x)
//{
// ll sum=0;
// while(x>0)
// {
// sum+=x%10;
// x/=10;
// }
// return sum;
//}
//
bool isPrime(ll n)
{
if (n <= 1)
return false;
if (n == 2 || n == 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (ll i = 5; i * i <= n; i += 6)
{
if (n % i == 0 || n % (i + 2) == 0)
return false;
}
return true;
}
ll MEX(vll v,ll n)
{
unordered_set<ll> s;
for (ll i = 0; i < n; ++i)
{
s.insert(v[i]);
}
for (ll i = 0; i <= n; ++i)
{
if (s.find(i) == s.end())
{
return i;
}
}
return n + 1;
}
bool isPalindrome(string s)
{
ll i=0,j=s.size()-1;
for(i,j; i<=j; i++,j--)
{
if(s[i]!=s[j]) return 0;
}
return 1;
}
//
//const ll mmx = 1e6;
//vll a(mmx); // Input array
//vll ST(mmx * 4); // Segment Tree array, 4 * n size for safety
//
//void build(int SI, int L, int R)
//{
// if (L == R)
// {
// ST[SI] = a[L];
// return;
// }
// int mid = (L + R) / 2;
// build(2 * SI, L, mid);
// build(2 * SI + 1, mid + 1, R);
// ST[SI] = min(ST[2 * SI], ST[2 * SI + 1]); // Change for other operations
//}
//
//int query(int SI, int rangeL, int rangeR, int l, int r)
//{
// if (rangeR < l || rangeL > r) return INT_MAX; // Outside range for min query
// if (rangeL >= l && rangeR <= r) return ST[SI]; // Completely inside
//
// int mid = (rangeL + rangeR) / 2;
// int leftResult = query(2 * SI, rangeL, mid, l, r);
// int rightResult = query(2 * SI + 1, mid + 1, rangeR, l, r);
// return min(leftResult, rightResult); // Change for other operations
//}
// // Segment Tree array, 4 * n size for safety
//
//vll st(mmx*4);
//void build1(int SI, int L, int R)
//{
// if (L == R)
// {
// st[SI] = a[L];
// return;
// }
// int mid = (L + R) / 2;
// build1(2 * SI, L, mid);
// build1(2 * SI + 1, mid + 1, R);
// st[SI] = max(st[2 * SI], st[2 * SI + 1]); // Change for other operations
//}
//
//int query1(int SI, int rangeL, int rangeR, int l, int r)
//{
// if (rangeR < l || rangeL > r) return INT_MIN; // Outside range for min query
// if (rangeL >= l && rangeR <= r) return st[SI]; // Completely inside
//
// int mid = (rangeL + rangeR) / 2;
// int leftResult = query1(2 * SI, rangeL, mid, l, r);
// int rightResult = query1(2 * SI + 1, mid + 1, rangeR, l, r);
// return max(leftResult, rightResult); // Change for other operations
//}
//vll sst(mmx*4);
//void build2(int SI, int L, int R) {
// if (L == R) {
// sst[SI] = L; // Store index at leaf node
// return;
// }
// int mid = (L + R) / 2;
// build2(2 * SI, L, mid);
// build2(2 * SI + 1, mid + 1, R);
//
// // Store index of the minimum element between left and right children
// sst[SI] = (a[sst[2 * SI]] <= a[sst[2 * SI + 1]]) ? sst[2 * SI] : sst[2 * SI + 1];
//}
//int query2(int SI, int rangeL, int rangeR, int l, int r) {
// if (rangeR < l || rangeL > r) return -1; // Out of range
//
// if (rangeL >= l && rangeR <= r) return sst[SI]; // Completely inside
//
// int mid = (rangeL + rangeR) / 2;
// int leftIndex = query2(2 * SI, rangeL, mid, l, r);
// int rightIndex = query2(2 * SI + 1, mid + 1, rangeR, l, r);
//
// // Determine the minimum index between left and right results
// if (leftIndex == -1) return rightIndex; // Only right is valid
// if (rightIndex == -1) return leftIndex; // Only left is valid
// return (a[leftIndex] <= a[rightIndex]) ? leftIndex : rightIndex;
//}
//vll stt(mmx * 4); // Segment Tree to store indices of max elements
//
//void build3(int SI, int L, int R) {
// if (L == R) {
// stt[SI] = L; // Store index at leaf node
// return;
// }
// int mid = (L + R) / 2;
// build3(2 * SI, L, mid);
// build3(2 * SI + 1, mid + 1, R);
//
// // Store index of the maximum element between left and right children
// stt[SI] = (a[stt[2 * SI]] >= a[stt[2 * SI + 1]]) ? stt[2 * SI] : stt[2 * SI + 1];
//}
//
//int query3(int SI, int rangeL, int rangeR, int l, int r) {
// if (rangeR < l || rangeL > r) return -1; // Out of range
//
// if (rangeL >= l && rangeR <= r) return stt[SI]; // Completely inside
//
// int mid = (rangeL + rangeR) / 2;
// int leftIndex = query3(2 * SI, rangeL, mid, l, r);
// int rightIndex = query3(2 * SI + 1, mid + 1, rangeR, l, r);
//
// // Determine the maximum index between left and right results
// if (leftIndex == -1) return rightIndex; // Only right is valid
// if (rightIndex == -1) return leftIndex; // Only left is valid
// return (a[leftIndex] >= a[rightIndex]) ? leftIndex : rightIndex;
//}
void solve()
{
ll n;
cin>>n;
vector<ll> v(n);
fr(i,0,n)cin>>v[i];
sort(all(v));
cout<<v[0]<<endl;
// map<int,int>mp;
// fr(i,0,n)mp[v[i]]=i;
// bool f=0;
// fr(i,0,n-3)
// {
// if(v[i]%2==0)
// {
// if(mp.find(v[i]+1)!=mp.end() && mp[v[i]+1]>i)
// {
// if(mp.find(v[i]+2)!=mp.end() && mp[v[i]+2]>mp[v[i]+1])
// {
// if(mp.find(v[i]+3)!=mp.end() && mp[v[i]+3]>mp[v[i]+2])
// {
// f=1;
// break;
// }
// }
//
// }
// }
// }
//
// if(f==1)cout<<"Yes"<<endl;
// else cout<<"No"<<endl;
}
int main()
{
khuaitian();
ll t=1;
//cin>>t;
ll c=0;
while(t--)
{
c++;
//cout<<"Case "<<c<<": ";
solve();
}
}
/*
6
1 2 1 1 3 5
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3812kb
input:
3 3 10 7
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 12ms
memory: 3856kb
input:
100000 154183567 764881828 59831034 828193326 391773598 487722171 451196811 245718514 750259573 762740115 821999084 28801227 218042831 918898632 881477122 891010192 55732830 509020430 594855913 455478382 456571462 705949609 471532655 550005603 861581472 984465652 883456918 463213251 626620153 371990...
output:
3772
result:
ok 1 number(s): "3772"
Test #3:
score: -100
Wrong Answer
time: 7ms
memory: 4000kb
input:
100000 80 88 53 77 74 63 57 71 75 74 27 14 38 23 24 75 33 89 81 33 100 56 53 77 55 54 63 80 100 15 70 24 100 65 95 22 34 12 31 30 83 20 68 87 23 53 53 55 72 13 57 94 27 94 93 81 96 57 11 81 18 53 34 67 77 65 38 45 45 33 66 47 56 61 60 55 13 61 60 83 24 68 88 50 59 44 27 99 22 82 16 96 62 60 98 48 78...
output:
10
result:
wrong answer 1st numbers differ - expected: '5', found: '10'