QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#858882#9773. Infinite LooplmhWA 53ms10052kbC++141.4kb2025-01-17 08:30:142025-01-17 08:30:15

Judging History

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

  • [2025-01-17 08:30:15]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:10052kb
  • [2025-01-17 08:30:14]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,q;
int a[100010],b[100010];
struct node {
    int day,time;
}days[3][100010];
signed main() {
    ios::sync_with_stdio(0);
    int sum=0;
    cin>>n>>k>>q;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i],sum+=b[i],a[i]--;
    int d=sum>k?sum:k;
    int last=0,day=1;
    for(int j=1;j<=2;j++)
        for(int i=1;i<=n;i++) {
            if(a[i]>last&&j==day||(j>day)) {
                days[j][i].time=a[i]+b[i];
                last=a[i]+b[i];
            }
            else {
                days[j][i].time=last+b[i];
                last+=b[i];
            }//    cout<<i<<"***"<<last<<"\n";
            if(last>k) {
                days[j][i].time-=k;
                last-=k;
                day++;
            }
            days[j][i].day=day;
        }
    // for(int i=1;i<=2;i++)
    //     for(int j=1;j<=n;j++)
    //         cout<<"day"<<i<<": no."<<j<<"   end on:"<<days[i][j].day<<"days "<<days[i][j].time+1<<"\n";
    for(int i=1;i<=q;i++) {
        int xx,yy;  cin>>xx>>yy;
        if(xx==1)
            cout<<days[1][yy].day<<" "<<days[1][yy].time<<"\n";
        else {
            int time=days[2][yy].time+(days[2][yy].day-1)*k+(xx-2)*d;
            int Day=time/k;
            int h=time%k;
            if(h==0)
                Day--,h=k;
            cout<<Day+1<<" "<<h<<"\n";
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 5 6
1 1
4 3
1 1
1 2
2 1
2 2
3 1
3 2

output:

1 1
2 1
2 2
3 1
3 2
4 1

result:

ok 12 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 7916kb

input:

3 10 5
2 4
3 1
10 7
2 2
7 1
4 3
5 2
28 3

output:

3 1
8 10
6 2
6 7
34 10

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 7912kb

input:

2 5 6
1 1
4 4
1 1
1 2
2 1
2 2
3 1
3 2

output:

1 1
2 2
2 3
3 2
3 3
4 2

result:

ok 12 numbers

Test #4:

score: 0
Accepted
time: 43ms
memory: 9044kb

input:

100000 100000000 100000
10 100000000
20 100000000
30 100000000
40 100000000
50 100000000
60 100000000
70 100000000
80 100000000
90 100000000
100 100000000
110 100000000
120 100000000
130 100000000
140 100000000
150 100000000
160 100000000
170 100000000
180 100000000
190 100000000
200 100000000
210 1...

output:

36129307020 9
26234983914 9
41309926070 9
46251938728 9
37943897764 9
18465580631 9
24057802725 9
46065927576 9
8562863275 9
19671679431 9
10995435094 9
45479963939 9
15142996651 9
37343630475 9
4867591081 9
26424135243 9
22968233395 9
33168452543 9
184417 9
5887110217 9
7946303466 9
12476713941 9
3...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 53ms
memory: 9640kb

input:

100000 100000000 100000
50000010 767
50000020 720
50000030 1043
50000040 383
50000050 457
50000060 123
50000070 255
50000080 478
50000090 422
50000100 1046
50000110 329
50000120 803
50000130 862
50000140 857
50000150 392
50000160 1022
50000170 572
50000180 324
50000190 190
50000200 1081
50000210 316...

output:

189472 75188938
6062 60058533
187817 72799176
175645 9027868
273552 97128926
404444 85017994
432526 76147901
73731 63080602
386838 65185635
441819 56238188
167074 56280428
16382 96188106
336596 76929886
89817 62078424
102256 70594211
297143 98092920
348605 51225880
100512 51308534
50244 4300467
3193...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 35ms
memory: 9728kb

input:

100000 100000000 100000
50000127 1000
50000215 1000
50000339 1000
50000430 1000
50000503 1000
50000618 1000
50000719 1000
50000828 1000
50000935 1000
50001042 1000
50001142 1000
50001227 1000
50001322 1000
50001427 1000
50001537 1000
50001614 1000
50001727 1000
50001846 1000
50001939 1000
50002033 1...

output:

247819 10560126
52586 74747126
165285 57999126
76095 28446126
311189 36444126
113026 35236126
468833 49208126
461379 58489126
461343 73204126
273160 15625126
76708 48154126
169963 88476126
361116 83206126
211711 74167126
488492 62905126
223889 88854126
488244 38684126
195751 97947126
481099 86969126...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 44ms
memory: 8544kb

input:

100000 100000000 100000
1000 1000
2000 1000
3000 1000
4000 1000
5000 1000
6000 1000
7000 1000
8000 1000
9000 1000
10000 1000
11000 1000
12000 1000
13000 1000
14000 1000
15000 1000
16000 1000
17000 1000
18000 1000
19000 1000
20000 1000
21000 1000
22000 1000
23000 1000
24000 1000
25000 1000
26000 1000...

output:

460111 57209999
21009 21670999
437826 72874999
25876 2384999
46024 40611999
185212 4077999
229465 73014999
142272 56857999
80327 8791999
423193 11199999
339075 2844999
362977 13634999
307570 13517999
286659 3388999
311342 1916999
435814 55677999
430055 12233999
120770 28293999
234566 34949999
479551...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 44ms
memory: 10052kb

input:

100000 100000000 100000
1000 936
2000 409
3000 53
4000 248
5000 1203
6000 94
7000 848
8000 1144
9000 1043
10000 287
11000 777
12000 1534
13000 1056
14000 1137
15000 574
16000 10
17000 1215
18000 715
19000 179
20000 932
21000 669
22000 1356
23000 573
24000 959
25000 298
26000 1228
27000 669
28000 729...

output:

24949 68723513
215451 69638185
479376 85436408
190908 93047593
139856 76967911
102561 98297832
93203 93564860
68516 45328252
197985 13674907
344751 77304687
16089 96249325
345704 84324745
458489 47046284
185536 32637058
40604 99089672
227059 55437284
420854 71183303
41872 92085780
373775 93531617
23...

result:

ok 200000 numbers

Test #9:

score: -100
Wrong Answer
time: 33ms
memory: 8020kb

input:

10000 100000000 100000
900 713
1800 223
2700 1094
3600 196
4500 1558
5400 404
6300 887
7200 243
8100 644
9000 1101
9900 226
10800 1143
11700 1127
12600 1164
13500 606
14400 1077
15300 1447
16200 624
17100 37
18000 307
18900 287
19800 270
20700 838
21600 843
22500 832
23400 1094
24300 1544
25200 1084...

output:

342324 5004474
492735 6845918
203143 2363977
169793 4932221
34066 1177195
152518 2720235
52182 1184106
24401 4764079
16480 4795147
122052 3001912
230137 5384807
90531 6801770
52064 7326346
310210 4403346
80567 6013642
164448 2085384
97469 8161077
14406 730258
293800 3160702
248298 7716959
470524 613...

result:

wrong answer 1st numbers differ - expected: '342325', found: '342324'