QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354104#7695. Double UpCaptainflyWA 2ms3808kbC++202.0kb2024-03-14 21:46:442024-03-14 21:46:44

Judging History

你现在查看的是最新测评结果

  • [2024-03-14 21:46:44]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3808kb
  • [2024-03-14 21:46:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
#define mp make_pair
inline int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
inline int lcm(int a, int b){return a / gcd(a, b) * b;}
const ll mod=1000000007;
ll qpow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline __int128 read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

inline void print(__int128 x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}

#define maxn 200010
__int128 a[maxn];
int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        a[i] = read();
    }
    __int128 ans = 0;
    for(int i=1;i<=n;i++)
    {
        __int128 mini = (__int128)1<<110,cnt = 0;
        for(int j=1;j<=n;j++) 
        {
            if(a[j]!=-1) 
            {
                if(a[j]<mini) mini = a[j];
                cnt++;
                // print(a[j]);
                // cout<<'\n';
                //printf("%Ld\n",a[i]);
            }
        }
        if(cnt==1)
        {
            ans = mini;
            break;
        }
        //print(mini);
        //cout<<'\n';
        for(int j=1;j<n;j++)
        {
            if(a[j]==-1) continue;
            if(a[j]==mini)
            {
                
                int r = j+1;
                while(r<=n&&a[r]==-1)r++;
                if(a[r]==a[j]) 
                {
                    a[r] = a[r]<<1,a[j] = -1;
                    //print(a[r]);
                }
                else a[j] = -1;
            }
        }
    }
    print(ans);
    return 0;

}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3716kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3808kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

wrong answer 1st lines differ - expected: '512', found: '0'